File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,6 @@ private List<Connection> connectionsOf(String cavern) {
5858 .collect (Collectors .toList ());
5959 }
6060
61-
6261 public void addBatCavern (String cavern ) {
6362 batCaverns .add (cavern );
6463 }
@@ -85,19 +84,23 @@ protected void moveWumpus() {
8584 wumpusChoices .add (wumpusCavern );
8685
8786 int nChoices = wumpusChoices .size ();
88- int choice = ( int ) ( Math . random () * nChoices );
87+ int choice = randomChoice ( nChoices );
8988 wumpusCavern = wumpusChoices .get (choice );
9089 }
9190
9291 private void randomlyTransportPlayer () {
9392 Set <String > transportChoices = new HashSet <>(caverns );
9493 transportChoices .remove (playerCavern );
9594 int nChoices = transportChoices .size ();
96- int choice = ( int ) ( Math . random () * nChoices );
95+ int choice = randomChoice ( nChoices );
9796 String [] choices = new String [nChoices ];
9897 playerCavern = transportChoices .toArray (choices )[choice ];
9998 }
10099
100+ private int randomChoice (int numberOfPossibleChoices ) {
101+ return (int ) (Math .random () * numberOfPossibleChoices );
102+ }
103+
101104 public void setQuiver (int arrows ) {
102105 this .quiver = arrows ;
103106 }
You can’t perform that action at this time.
0 commit comments