1 package net.innig.macker.example.modularity.game.impl; 2 3 import net.innig.macker.example.modularity.game.*; 4 import net.innig.util.EnumeratedType; 5 import java.util.*; 6 7 public final class RochambeauMove 8 extends EnumeratedType 9 implements Move 10 { 11 static final Move 12 SCISSORS = new RochambeauMove("scissors", 0), 13 PAPER = new RochambeauMove("paper", 1), 14 STONE = new RochambeauMove("stone", 2); 15 16 static final Set ALL = Collections.unmodifiableSet(new HashSet(Arrays.asList( 17 new Move[] { SCISSORS, PAPER, STONE } ))); 18 19 private RochambeauMove(String name, int num) 20 { 21 super(name); 22 this.num = num; 23 } 24 25 public int getScoreFor(Move other) 26 { return ((num + 1) % 3 == ((RochambeauMove) other).num) ? 1 : 0; } 27 28 private int num; 29 } 30 | Popular Tags |