1 package nl.tudelft.goal.ut2004.messages; 2 3 public enum FireMode { 4 5 PRIMARY(1), SECONDARY(2), NONE(0); 6 7 private int mode; 8 private FireMode(int mode){ 9 this.mode = mode; 10 } 11 public boolean isPrimary() { 12 return this == PRIMARY; 13 } 14 15 public int id(){ 16 return mode; 17 } 18 19 public static FireMode valueOfIgnoreCase(String firemode) { 20 return valueOf(firemode.toUpperCase()); 21 } 22 23 public static Object valueOf(Boolean primaryShooting, Boolean secondaryShooting) { 24 if (primaryShooting != null && primaryShooting) 25 return PRIMARY; 26 if (secondaryShooting != null && secondaryShooting) 27 return SECONDARY; 28 return NONE; 29 } 30 31 public static Object valueOf(int mode) { 32 for(FireMode m : FireMode.values()){ 33 if(m.mode == mode){ 34 return m; 35 } 36 } 37 38 throw new IllegalArgumentException(); 39 } 40 41 }