MCPcopy Create free account
hub / github.com/BruceEckel/OnJava8-Examples / newItem

Method newItem

enums/RoShamBo1.java:13–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11 static final int SIZE = 20;
12 private static Random rand = new Random(47);
13 public static Item newItem() {
14 switch(rand.nextInt(3)) {
15 default:
16 case 0: return new Scissors();
17 case 1: return new Paper();
18 case 2: return new Rock();
19 }
20 }
21 public static void match(Item a, Item b) {
22 System.out.println(
23 a + " vs. " + b + ": " + a.compete(b));

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected