2015-09-07 11:44:36 -06:00
|
|
|
|
// enums/RoShamBo.java
|
2015-11-14 16:18:05 -08:00
|
|
|
|
// <20>2016 MindView LLC: see Copyright.txt
|
2015-06-15 17:47:35 -07:00
|
|
|
|
// Common tools for RoShamBo examples.
|
|
|
|
|
package enums;
|
2015-11-11 20:20:04 -08:00
|
|
|
|
import onjava.*;
|
2015-06-15 17:47:35 -07:00
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
|
}
|