PhraseSolver Java
PhraseSolver Java
PhraseSolver Java
* Activity 2.5.2
*
* The PhraseSolver class the PhraseSolverGame
*/
import java.util.Scanner;
This study source was downloaded by 100000835025530 from CourseHero.com on 01-30-2024 23:14:54 GMT -06:00
https://www.coursehero.com/file/101811162/PhraseSolverjava/
}
else if(player2.getPoints()>player1.getPoints()) {
System.out.println(player2.getName() + " wins with the highest
score!");
}
else{
System.out.println(player1.getName() + " and " + player2.getName() +
" ties the game!");
}
}
}
else if(guess.equals("try phrase")) {
currentPlayer = 0;
playerGuessPhrase = 1;
guessPhrase = true;
}
else if (!correct){
System.out.println("Your guess was incorrect!");
currentPlayer = 2;
}
}
while (currentPlayer == 2) {
System.out.println("Current phrase solved: " + game.getSolvedPhrase());
System.out.println("Point value of the next letter guess: " +
game.getCurrentLetterValue());
System.out.println("Current player name: " + player2.getName());
System.out.println("Player points: " + player2.getPoints());
System.out.println("Type in a guess(type in a letter, for guessing the
entire phrase or when it is revealed, type in \" try phrase\"): ");
guess = input.nextLine();
correct = game.guessLetter(guess);
if (guess.length() == 1 && correct){
System.out.println("You got it correct! You will receive " +
game.getCurrentLetterValue() + " points.");
player2.addToPoints(game.getCurrentLetterValue());
game.setLetterValue();
if (game.getSolvedPhrase().indexOf("_") == -1){
currentPlayer = 0;
solved = true;
System.out.println("You have solved the phrase!");
if (player1.getPoints()>player2.getPoints()){
System.out.println(player1.getName() + " wins with the highest
score!");
}
else if(player2.getPoints()>player1.getPoints()) {
System.out.println(player2.getName() + " wins with the highest
score!");
}
else{
System.out.println(player1.getName() + " and " + player2.getName()
+ " ties the game!");
}
}
}
else if(guess.equals("try phrase")) {
currentPlayer = 0;
playerGuessPhrase = 2;
guessPhrase = true;
This study source was downloaded by 100000835025530 from CourseHero.com on 01-30-2024 23:14:54 GMT -06:00
https://www.coursehero.com/file/101811162/PhraseSolverjava/
}
else if (!correct){
System.out.println("You guess was incorrect!");
currentPlayer = 1;
}
}
This study source was downloaded by 100000835025530 from CourseHero.com on 01-30-2024 23:14:54 GMT -06:00
https://www.coursehero.com/file/101811162/PhraseSolverjava/
Powered by TCPDF (www.tcpdf.org)