mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-03-03 16:49:45 +01:00
Utvider RobotID slik at den kan representeres som et tall
This commit is contained in:
parent
2835a253fa
commit
aa06d5df6c
@ -4,12 +4,44 @@ package inf112.fiasko.roborally.element_properties;
|
||||
* This class represents an id for marking specific robots
|
||||
*/
|
||||
public enum RobotID {
|
||||
ROBOT_1,
|
||||
ROBOT_2,
|
||||
ROBOT_3,
|
||||
ROBOT_4,
|
||||
ROBOT_5,
|
||||
ROBOT_6,
|
||||
ROBOT_7,
|
||||
ROBOT_8
|
||||
ROBOT_1 (1),
|
||||
ROBOT_2 (2),
|
||||
ROBOT_3 (3),
|
||||
ROBOT_4 (4),
|
||||
ROBOT_5 (5),
|
||||
ROBOT_6 (6),
|
||||
ROBOT_7 (7),
|
||||
ROBOT_8 (8);
|
||||
|
||||
private final int robotID;
|
||||
|
||||
/**
|
||||
* Constructor to let a robotID be represented by a numerical identifier
|
||||
* @param robotID <p>The numerical identifier assigned to the robot ID</p>
|
||||
*/
|
||||
RobotID(int robotID) {
|
||||
this.robotID = robotID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the numerical id used for identification of a robot id
|
||||
* @return <p>The numerical id of the robot id</p>
|
||||
*/
|
||||
public int getRobotIDID() {
|
||||
return this.robotID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a robot ID value from its numerical representation
|
||||
* @param robotID <p>The numerical representation of a robot id</p>
|
||||
* @return <p>The enum value representing the robot ID, or null if the id is invalid</p>
|
||||
*/
|
||||
public static RobotID getRobotIDFromID(int robotID) {
|
||||
for (RobotID type : RobotID.values()) {
|
||||
if (type.robotID == robotID) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user