From 24380733bf7209cd7034a97e6dc3cf0656af06e9 Mon Sep 17 00:00:00 2001 From: CedricNew Date: Sat, 7 Jan 2023 16:34:36 +0100 Subject: [PATCH] =?UTF-8?q?Sicherheits=C3=A4nderung=20wegen=20falschen=20Z?= =?UTF-8?q?ugriffsrechten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain/Factory.java | 12 +++++++++++- facade/FactorySystem.java | 14 +++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/domain/Factory.java b/domain/Factory.java index 71a2c0d..70f793d 100644 --- a/domain/Factory.java +++ b/domain/Factory.java @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.HashMap; public class Factory implements Serializable { + private HashMap robots = new HashMap<>(); private int c3poID = 0; private int r2d2ID = 10000; @@ -14,10 +15,19 @@ public class Factory implements Serializable { } //Has to return Collection - public Collection getRobotList(){ + public Collection robotListToCollection(){ return robots.values(); } + public String[] getRobotList() { + Collection collect = robotListToCollection(); + String[] list = new String[collect.size()]; + int i = 0; + for(Robot r: collect){ + list[i++] = r.toString(); + } + return list; + } public boolean buildNewRobot(String name, int type){ Robot r ; if(type == 0){ diff --git a/facade/FactorySystem.java b/facade/FactorySystem.java index 594242b..1d9d3aa 100644 --- a/facade/FactorySystem.java +++ b/facade/FactorySystem.java @@ -1,9 +1,7 @@ package facade; -import java.io.FileNotFoundException; -import java.util.Collection; -import java.util.HashMap; -import domain.*; +import domain.Factory; +import domain.Robot; import infrastructure.Persistenz; public class FactorySystem { @@ -28,13 +26,7 @@ public class FactorySystem { } public String[] getAllRobots(){ - Collection robots = factory.getRobotList(); - String[] list = new String[robots.size()]; - int i = 0; - for(Robot r: robots){ - list[i++] = r.toString(); - } - return list; + return factory.getRobotList(); } public boolean buildNewRobot(String name, int type){