From 3bcff6941cc0facafadfbdaaededb3fecf27c104 Mon Sep 17 00:00:00 2001 From: Milan Lukic <2122158@stud.hs-mannheim.de> Date: Wed, 4 Jan 2023 12:46:13 +0100 Subject: [PATCH] RobotFactory Klasse erstellt und die Methode addRoboter implementiert --- Roboterfabrik/src/Domäne/RobotFactory.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Roboterfabrik/src/Domäne/RobotFactory.java diff --git a/Roboterfabrik/src/Domäne/RobotFactory.java b/Roboterfabrik/src/Domäne/RobotFactory.java new file mode 100644 index 0000000..b311fc9 --- /dev/null +++ b/Roboterfabrik/src/Domäne/RobotFactory.java @@ -0,0 +1,30 @@ +package Domäne; + +import java.util.HashMap; + +public class RobotFactory { +private String name; +private HashMap roboters = new HashMap<>(); + +public RobotFactory (String name) { + this.name = name; +} + + public int addRoboter (RobotType robotType) { + Roboter roboter; + + if (RobotType.R2D2 == robotType) { + roboter = new R2D2 ("R2D2"); + roboters.put(roboter.getId(), roboter); + return roboter.getId(); + } + else if (RobotType.C3PO == robotType) { + roboter = new C3PO ("C3PO"); + roboters.put(roboter.getId(), roboter); + return roboter.getId(); + + } + else + return -1; + } +}