// // // import static choco.Choco.*; import choco.kernel.model.Model; import choco.kernel.model.variables.integer.IntegerVariable; import java.util.*; public class Round { int roundNo; // the round number ArrayList match; // matches within a round int numberOfBoats; // number of boats that can be used Round(int roundNo, int numberOfBoats){ this.roundNo = roundNo; this.numberOfBoats = numberOfBoats; match = new ArrayList(); } void add(Match m){match.add(m);} // // add a match to the round // void allDifferentBoats(Model model){ int n = match.size()*2; IntegerVariable[] boat = new IntegerVariable[n]; int i=0; for (Match m : match){ boat[i++] = m.boat1; boat[i++] = m.boat2; } model.addConstraint(allDifferent(boat)); } // // every boat used in the matches of a round must be different // i.e. one man in a boat // public String toString(){ String s = ""; for (Match m : match) s = s + m +" "; return s; } }