From 1d9e1b3d436aceae8d0bc5c2ffb265241f077d20 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Mon, 23 Mar 2020 12:29:36 +0100 Subject: [PATCH] Legger til en partikkeltype klasse --- .../element_properties/ParticleType.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/inf112/fiasko/roborally/element_properties/ParticleType.java diff --git a/src/main/java/inf112/fiasko/roborally/element_properties/ParticleType.java b/src/main/java/inf112/fiasko/roborally/element_properties/ParticleType.java new file mode 100644 index 0000000..3bbdac0 --- /dev/null +++ b/src/main/java/inf112/fiasko/roborally/element_properties/ParticleType.java @@ -0,0 +1,40 @@ +package inf112.fiasko.roborally.element_properties; + +public enum ParticleType { + LASER_BEAM_SINGLE (1), + LASER_BEAM_DOUBLE (2), + LASER_BEAM_SINGLE_CROSS (3), + LASER_BEAM_DOUBLE_CROSS (4); + + private final int particleTypeID; + + /** + * Constructor to let a particle type be represented by a numerical identifier + * @param particleTypeID

The numerical identifier assigned to the particle type

+ */ + ParticleType(int particleTypeID) { + this.particleTypeID = particleTypeID; + } + + /** + * Gets the numerical id used for alternate identification of a tile type + * @return

The numerical id of the tile type

+ */ + public int getParticleTypeID() { + return this.particleTypeID; + } + + /** + * Gets a particle type value from its numerical representation + * @param particleTypeID

The numerical representation of a particle type

+ * @return

The enum value representing the particle type, or null if the id is invalid

+ */ + public static ParticleType getParticleTypeFromID(int particleTypeID) { + for (ParticleType type : ParticleType.values()) { + if (type.particleTypeID == particleTypeID) { + return type; + } + } + return null; + } +}