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

View File

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