From a12278c48be2ec554a3c091d4142bc87bdbae34b Mon Sep 17 00:00:00 2001 From: Milan Lukic <2122158@stud.hs-mannheim.de> Date: Wed, 4 Jan 2023 14:49:06 +0100 Subject: [PATCH] Nexus6 Roboter als Singleton umgesetzt --- Roboterfabrik/src/Domäne/Nexus6.java | 47 ++++++++++++++++++++++ Roboterfabrik/src/Domäne/RobotFactory.java | 10 ++++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 Roboterfabrik/src/Domäne/Nexus6.java diff --git a/Roboterfabrik/src/Domäne/Nexus6.java b/Roboterfabrik/src/Domäne/Nexus6.java new file mode 100644 index 0000000..79020f1 --- /dev/null +++ b/Roboterfabrik/src/Domäne/Nexus6.java @@ -0,0 +1,47 @@ +package Domäne; + +import Exception.RobotException; +import Exception.RobotIllegalStateException; + +public class Nexus6 extends Roboter { + + String name; + int id; + private static Nexus6 pris; + + + private Nexus6() { + super("Pris"); + this.id = 19_281_982; + + + } + + + + public static Nexus6 getInstance () { + if (pris == null) { + pris = new Nexus6(); + } + return pris; + } + + @Override + public void triggerPowerSwitch() { + power = false; + } + + + @Override + public int getId() { + return id; + } + + @Override + public int[] think(int[] zahlen)throws RobotException { + + + return null; + } + +} diff --git a/Roboterfabrik/src/Domäne/RobotFactory.java b/Roboterfabrik/src/Domäne/RobotFactory.java index b311fc9..5129745 100644 --- a/Roboterfabrik/src/Domäne/RobotFactory.java +++ b/Roboterfabrik/src/Domäne/RobotFactory.java @@ -10,7 +10,7 @@ public RobotFactory (String name) { this.name = name; } - public int addRoboter (RobotType robotType) { + public int addRobot (RobotType robotType) { Roboter roboter; if (RobotType.R2D2 == robotType) { @@ -27,4 +27,12 @@ public RobotFactory (String name) { else return -1; } + + public String getName() { + return name; + } + + public Roboter findeRoboter (int id) { + return roboters.get(id); + } }