-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuessTheFilm.java
34 lines (30 loc) · 1.76 KB
/
GuessTheFilm.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package guess.the.film;
import java.util.*;
import java.io.*;
public class GuessTheFilm {
public static void main(String[] args) throws Exception{
Game game = new Game();
System.out.println("Welcome to Guess the Movie!");
System.out.println("The rules are simple, I can randomly pick a movie title, and show you how many letters it's made up of.");
System.out.println("Your goal is to try to figure out the movie by guessing one letter at a time.");
System.out.println("If a letter exists in the title I will reveal its correct position in the word, if not, you lose a point.");
System.out.println("If you lose 10 points, game over!");
System.out.println("Let's start!");
System.out.println("The movie title has " + game.getMovieTitle().length() + " characters (including spaces and punctuation).");
while(game.gameEnded()==false){
System.out.println("You are guessing:" + game.getHiddenMovieTitle());
System.out.println("You have guessed (" + (game.getWrongLetters().length()/2) + ") wrong letters:" + game.getWrongLetters());// /2 because of space after each letter
game.guessLetter();
}
if(game.WonGame()){
System.out.println("You win!");
System.out.println("You have guessed '" + game.getMovieTitle() + "' correctly.");
}
else{
System.out.println("You have guessed (" + game.getWrongLetters().length()/2 + ") wrong letters:" +game.getWrongLetters());
System.out.println("You lost!");
System.out.println("The movie title was '" + game.getMovieTitle()+"'") ;
System.out.println("Better luck next time.");
}
}
}