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][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][L][ ][ ][ ][ ]
public class PlayBaffleGame { public static void main (String [] args) { /*ask the user which level of difficulty they would like to play and then display the game chosen board*/ initializeBoard(null); int difficulty; Scanner input= new Scanner(System.in); System.out.println("Please choose a level of difficulty"); System.out.println("1. Beginner: four baffles"); System.out.println("2. Intermediate: seven baffles"); System.out.println("3. Advanced: ten baffles "); difficulty= input.nextInt(); int BaffleCount=0; switch(difficulty) { case 1: //while loop to crate four baffles while(BaffleCount<4) { System.out.println("BAFFLE"+ (BaffleCount+1)+":"); getBaffles(); BaffleCount++; } break; case 2: //while loop to create seven baffles while(BaffleCount<7) { System.out.println("BAFFLE"+ (BaffleCount+1)+":"); getBaffles(); BaffleCount++; } break; case 3: //while loop to create ten baffles while(BaffleCount<10) { System.out.println("BAFFLE"+ (BaffleCount+1)+":"); getBaffles(); BaffleCount++; } break; } //end switch for difficulty }//end main method //create method that uses random generated numbers to assign baffles a space public static void getBaffles() { int row= (int) (Math.random()*9+1); int col=(int) (Math.random()*9+1); int direction=(int)(Math.random()*2+1); for (int i = 0; i < 10; i++){ for (int j = 0; j < 10; j++){ if(i==row&&j==col) { if(direction==1) System.out.print("[R]"); else if(direction==2) System.out.print("[L]"); } else System.out.print("[ ]"); } System.out.println(); } }//end getBaffles
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)