diff --git a/src/player/Human.java b/src/player/Human.java index 9263c36..84d792e 100644 --- a/src/player/Human.java +++ b/src/player/Human.java @@ -1,6 +1,9 @@ package player; import java.util.Scanner; +import java.util.HashSet; +import java.util.Set; +import java.util.Arrays; public class Human implements Player { @@ -17,8 +20,18 @@ public class Human implements Player { @Override public int move(int[][] board) { - System.out.print("Choose a move: "); - return sc.nextInt(); + Set options = new HashSet<>(Arrays.asList(0,1,2,3,4,5,6)); + for (Integer i: new HashSet(options)) { + if (board[i][0] != 0) { + options.remove(i); + } + } + int choice = -1; + while (!options.contains(new Integer(choice))) { + System.out.print("Choose a move from " + options + ": "); + choice = sc.nextInt(); + } + return choice; } @Override