diff --git a/src/C3PO.java b/src/C3PO.java index fdc0ce8..54499b3 100644 --- a/src/C3PO.java +++ b/src/C3PO.java @@ -7,9 +7,12 @@ import java.util.stream.Collectors; public class C3PO implements Robot { private int id; private String name; - private boolean isPowerOn; - + private boolean isPowerOn=false; +public C3PO(int id, String name){ + this.id=id; + this.name=name; +} @Override public int getId() { diff --git a/src/R2D2.java b/src/R2D2.java index 4deef9a..104def9 100644 --- a/src/R2D2.java +++ b/src/R2D2.java @@ -9,6 +9,11 @@ public class R2D2 implements Robot { private String name; private boolean isPowerOn; + public R2D2(int id, String name){ + this.id=id; + this.name=name; + } + @Override diff --git a/src/RobotFactory.java b/src/RobotFactory.java new file mode 100644 index 0000000..052efd9 --- /dev/null +++ b/src/RobotFactory.java @@ -0,0 +1,21 @@ +import tpe.exceptions.roboter.Robot; + +public class RobotFactory { + private static int R2D2Id=0; + private static int C2POId=10000; + public static Robot getRobot(String typ){ + switch (typ){ + case "R2D2": + return new R2D2(R2D2Id++,"blah"); + + case "C3PO": + return new C3PO(C2POId++,"blah"); + + case "Nexus6": + return Nexus6.getInstance(); + + } + return null; + } + +}