From 1846c66dc58f0d0756ea8f33257f6f1662293f13 Mon Sep 17 00:00:00 2001 From: Eline Date: Mon, 9 Jan 2023 13:04:32 +0100 Subject: [PATCH] added Robotexception getLastException --- src/main/java/roboter/C3PO.java | 6 ++++-- src/main/java/roboter/R2D2.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/roboter/C3PO.java b/src/main/java/roboter/C3PO.java index 8927458..69dec7a 100644 --- a/src/main/java/roboter/C3PO.java +++ b/src/main/java/roboter/C3PO.java @@ -2,6 +2,7 @@ package roboter; import roboter.exceptions.RobotException; +import java.util.ArrayList; import java.util.Arrays; import java.util.stream.Collectors; @@ -9,7 +10,8 @@ public class C3PO implements Robot { private int id; private String name; private boolean isPowerOn=false; - + ArrayList exceptionList=new ArrayList<>(); + public C3PO(int id, String name){ this.id=id; this.name=name; @@ -42,7 +44,7 @@ public C3PO(int id, String name){ @Override public RobotException getLastException() { - return null; + return exceptionList.get(exceptionList.size()-1); } @Override diff --git a/src/main/java/roboter/R2D2.java b/src/main/java/roboter/R2D2.java index 41de9f8..93895d6 100644 --- a/src/main/java/roboter/R2D2.java +++ b/src/main/java/roboter/R2D2.java @@ -2,6 +2,7 @@ package roboter; import roboter.exceptions.RobotException; +import java.util.ArrayList; import java.util.Arrays; import java.util.stream.Collectors; @@ -9,7 +10,8 @@ public class R2D2 implements Robot { private int id; private String name; private boolean isPowerOn; - + ArrayList exceptionList=new ArrayList<>(); + public R2D2(int id, String name){ this.id=id; this.name=name; @@ -43,7 +45,7 @@ public class R2D2 implements Robot { @Override public RobotException getLastException() { - return null; + return exceptionList.get(exceptionList.size()-1); } @Override