From 310970b220c838308852fc7bbb7f5faefc36cea7 Mon Sep 17 00:00:00 2001 From: 2120940 <2120940@stud.hs-mannheim.de> Date: Mon, 9 Jan 2023 11:34:00 +0100 Subject: [PATCH] ID Generator angepasst --- Roboter/tpe/exceptions/roboter/RobotFactory.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Roboter/tpe/exceptions/roboter/RobotFactory.java b/Roboter/tpe/exceptions/roboter/RobotFactory.java index a0447e6..e623229 100644 --- a/Roboter/tpe/exceptions/roboter/RobotFactory.java +++ b/Roboter/tpe/exceptions/roboter/RobotFactory.java @@ -18,33 +18,33 @@ public class RobotFactory { Robots robot; if(RobotType.R2D2==robotType) { - robot=new R2D2(name, createIDR2D2(0,9999)); + robot=new R2D2(name, createIDR2D2(10000)); robotStock.put(robot.getId(), robot); return robot.getId(); } else { - robot=new C3PO(name, createIDC3PO(10000, 19999)); + robot=new C3PO(name, createIDC3PO(10000)); robotStock.put(robot.getId(), robot); return robot.getId(); } } - private int createIDR2D2(int minValue, int maxValue) { + private int createIDR2D2(int value) { - int randomID = (int) (Math.random()*(maxValue)) ; + int randomID = (int) (Math.random()*(value)) ; if(robotStock.containsKey(randomID)) { - createIDR2D2(minValue,maxValue); + createIDR2D2(value); } return randomID; } - private int createIDC3PO(int minValue, int maxValue) { + private int createIDC3PO(int value) { - int randomID = (int) (Math.random()*(maxValue))+minValue ; + int randomID = (int) (Math.random()*(value))+value ; if(robotStock.containsKey(randomID)) { - createIDC3PO(minValue,maxValue); + createIDC3PO(value); } return randomID; }