Command.java
1 package hlt; 2 3 public class Command { 4 public final String command; 5 6 public static Command spawnShip() { 7 return new Command("g"); 8 } 9 10 public static Command transformShipIntoDropoffSite(final EntityId id) { 11 return new Command("c " + id); 12 } 13 14 public static Command move(final EntityId id, final Direction direction) { 15 return new Command("m " + id + ' ' + direction.charValue); 16 } 17 18 private Command(final String command) { 19 this.command = command; 20 } 21 22 @Override 23 public boolean equals(Object o) { 24 if (this == o) return true; 25 if (o == null || getClass() != o.getClass()) return false; 26 27 Command command1 = (Command) o; 28 29 return command.equals(command1.command); 30 } 31 32 @Override 33 public int hashCode() { 34 return command.hashCode(); 35 } 36 37 @Override 38 public String toString() { 39 return command; 40 } 41 }