import java.util.Scanner; public class Player { private char color; public Player(char color) { this.color = color; } public char getColor() { return color; } /** * Prompt the user for an int to represent the column * where the user wants to place her checker. * Validates that the number is a valid column (1-7). * @return - an int 0-6 */ public int getPosition() { Scanner s = new Scanner(System.in); System.out.println("Player " + color + "\n\tPlease enter a column number: "); int choice = s.nextInt(); int numChoices = 1; while((choice < 1 || choice > 7) && numChoices < 3) { System.out.println("Sorry, bad choice. Enter another (1-7): "); choice = s.nextInt(); numChoices++; } if(numChoices >= 3) { System.out.println("Too many choices"); System.exit(0); } return choice-1; } public static void main(String[] args) { Player red = new Player('R'); Player black = new Player('B'); System.out.println("You chose: " + red.getPosition()); } }