From 4498d916ddf351f26f8bad9bf7fa037e5a4815b2 Mon Sep 17 00:00:00 2001 From: cedri Date: Sat, 7 Jan 2023 19:29:12 +0100 Subject: [PATCH] Robotermodellklasse angelegt + Konstruktor der beiden Modelle --- Robbie-Management-System/src/domain/C3PO.java | 8 ++++++-- Robbie-Management-System/src/domain/R2D2.java | 8 ++++++-- .../src/domain/RobotFactory.java | 1 + .../src/domain/Robotermodelle.java | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 Robbie-Management-System/src/domain/Robotermodelle.java diff --git a/Robbie-Management-System/src/domain/C3PO.java b/Robbie-Management-System/src/domain/C3PO.java index fd30d67..184cb36 100644 --- a/Robbie-Management-System/src/domain/C3PO.java +++ b/Robbie-Management-System/src/domain/C3PO.java @@ -2,10 +2,14 @@ package domain; import roboterSystem.Robot; -public class C3PO implements Robot { +public class C3PO extends Robotermodelle implements Robot { + + private int zähler = 10000; public C3PO(String name) { - // TODO Auto-generated constructor stub + setName(name); + setiD(zähler); + zähler++; } diff --git a/Robbie-Management-System/src/domain/R2D2.java b/Robbie-Management-System/src/domain/R2D2.java index 653239b..600ec1f 100644 --- a/Robbie-Management-System/src/domain/R2D2.java +++ b/Robbie-Management-System/src/domain/R2D2.java @@ -2,10 +2,14 @@ package domain; import roboterSystem.Robot; -public class R2D2 implements Robot { +public class R2D2 extends Robotermodelle implements Robot { + private int zähler = 0; + public R2D2(String name) { - // TODO Auto-generated constructor stub + setName(name); + setiD(zähler); + zähler++; } diff --git a/Robbie-Management-System/src/domain/RobotFactory.java b/Robbie-Management-System/src/domain/RobotFactory.java index c85474f..1fda10c 100644 --- a/Robbie-Management-System/src/domain/RobotFactory.java +++ b/Robbie-Management-System/src/domain/RobotFactory.java @@ -12,5 +12,6 @@ public class RobotFactory { case "R2D2": return new R2D2(name); } + return null; } } diff --git a/Robbie-Management-System/src/domain/Robotermodelle.java b/Robbie-Management-System/src/domain/Robotermodelle.java new file mode 100644 index 0000000..8e25952 --- /dev/null +++ b/Robbie-Management-System/src/domain/Robotermodelle.java @@ -0,0 +1,16 @@ +package domain; + +public class Robotermodelle { + private int iD; + private String name; + private boolean power = true; + + public void setName(String name) { + this.name = name; + } + + public void setiD(int iD) { + this.iD = iD; + } + +}