Sudoku Puzzle Project assignment help

computer science

Description

public static void main(String[] args) {

Scanner reader = new Scanner(System.in);

System.out.println("Sudoku Game: ");

SudokuPuzzle puzzle = new SudokuPuzzle();

puzzle.initializePuzzle(puzzle);

System.out.print("The puzzle is: \n" + puzzle);

boolean done = false;

while(!done){

System.out.println("What would you like to do? \n" +

"Clear Puzzle(C) Set a square (S) Get possible values (G) Quit (Q) ");

String response = reader.next();

response = response.toLowerCase();

if(response.equals("q")){

System.out.println("Thanks for playing.");

done = true;

} else if(response.equals("s")){

System.out.println("Which row (1-9) and colume (1-9) do you want to change?");

int row = reader.nextInt()-1;

int col = reader.nextInt()-1;

System.out.println("What should the value (1-9) be?");

int value = reader.nextInt();

puzzle.addGuess(row, col, value);

} else if(response.equals("g")){

System.out.println("Which row (1-9) and colume (1-9) do you want to get values for?");

int row = reader.nextInt()-1;

int col = reader.nextInt()-1;

boolean valid[] = puzzle.getAllowedValues(row, col);

System.out.print("Allowed values are: ");

for(int i=0; i<9; i++){

if(valid[i])

System.out.print((i+1)+ " ");

}

System.out.println();

} else if(response.equals("c")){

puzzle.reset();

}

System.out.print("The puzzle is now: \n" + puzzle);

if(!puzzle.checkPuzzle())

System.out.println("You have made an error in the puzzle.");

else if(puzzle.isFull())

System.out.println("Congratulations, you have completed the puzzle.");

Instruction Files

Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.