added Robotexception getLastException

master
Eline 2023-01-09 13:04:32 +01:00
parent adca32b401
commit 1846c66dc5
2 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package roboter;
import roboter.exceptions.RobotException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;
@ -9,6 +10,7 @@ public class C3PO implements Robot {
private int id;
private String name;
private boolean isPowerOn=false;
ArrayList<RobotException> exceptionList=new ArrayList<>();
public C3PO(int id, String name){
this.id=id;
@ -42,7 +44,7 @@ public C3PO(int id, String name){
@Override
public RobotException getLastException() {
return null;
return exceptionList.get(exceptionList.size()-1);
}
@Override

View File

@ -2,6 +2,7 @@ package roboter;
import roboter.exceptions.RobotException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;
@ -9,6 +10,7 @@ public class R2D2 implements Robot {
private int id;
private String name;
private boolean isPowerOn;
ArrayList<RobotException> exceptionList=new ArrayList<>();
public R2D2(int id, String name){
this.id=id;
@ -43,7 +45,7 @@ public class R2D2 implements Robot {
@Override
public RobotException getLastException() {
return null;
return exceptionList.get(exceptionList.size()-1);
}
@Override