generated from hummel/Bank-System
ID Generator angepasst
parent
5684f0df51
commit
310970b220
|
@ -18,33 +18,33 @@ public class RobotFactory {
|
||||||
Robots robot;
|
Robots robot;
|
||||||
|
|
||||||
if(RobotType.R2D2==robotType) {
|
if(RobotType.R2D2==robotType) {
|
||||||
robot=new R2D2(name, createIDR2D2(0,9999));
|
robot=new R2D2(name, createIDR2D2(10000));
|
||||||
robotStock.put(robot.getId(), robot);
|
robotStock.put(robot.getId(), robot);
|
||||||
return robot.getId();
|
return robot.getId();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
robot=new C3PO(name, createIDC3PO(10000, 19999));
|
robot=new C3PO(name, createIDC3PO(10000));
|
||||||
robotStock.put(robot.getId(), robot);
|
robotStock.put(robot.getId(), robot);
|
||||||
return robot.getId();
|
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))
|
if(robotStock.containsKey(randomID))
|
||||||
{
|
{
|
||||||
createIDR2D2(minValue,maxValue);
|
createIDR2D2(value);
|
||||||
}
|
}
|
||||||
return randomID;
|
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))
|
if(robotStock.containsKey(randomID))
|
||||||
{
|
{
|
||||||
createIDC3PO(minValue,maxValue);
|
createIDC3PO(value);
|
||||||
}
|
}
|
||||||
return randomID;
|
return randomID;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue