OnJava8-Examples/enums/RoShamBo.java
Bruce Eckel 186333e022 enums
2015-05-31 10:58:40 -07:00

20 lines
524 B
Java

//: enums/RoShamBo.java
// ©2015 MindView LLC: see Copyright.txt
// Common tools for RoShamBo examples.
package enums;
import net.mindview.util.*;
public class RoShamBo {
public static <T extends Competitor<T>>
void match(T a, T b) {
System.out.println(
a + " vs. " + b + ": " + a.compete(b));
}
public static <T extends Enum<T> & Competitor<T>>
void play(Class<T> rsbClass, int size) {
for(int i = 0; i < size; i++)
match(
Enums.random(rsbClass),Enums.random(rsbClass));
}
} ///:~