Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void playerMove(Piece thePiece){
- boolean validInput = false;
- do{
- if (thePiece == Piece.Cross){
- System.out.println("Player 1's turn (X), please enter a number between 1-7 to choose which colum to place your piece");
- } else{
- System.out.println("Player 2's turn (0), please enter a number between 1-7 to choose which colum to place your piece");
- }
- int col = in.nextInt() - 1;
- if ((0 <= col && col < 7)){
- validInput = true;
- }
- else{
- System.out.println("Move placed on " + (col +1) + ", is not valid, please enter again");
- }
- if(board.position[0][col].content!=Piece.Empty)
- {
- validInput = false;
- System.out.println("The Column is already full. Please Select Another Column");
- continue;
- }
- for(int h = 5; h>= 0; h--){
- if(board.position[h][col].content==Piece.Empty){
- {
- board.position[h][col].content=thePiece;
- return;
- }
- }
- }
- } while (!validInput);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement