Millionaire Java Game: Who Wants To Be A
private boolean askQuestion(Question q) System.out.println("\n" + q.text); for (int i = 0; i < 4; i++) System.out.println((char) ('A' + i) + ": " + q.options[i]);
public void start() System.out.println("====================================="); System.out.println(" WHO WANTS TO BE A MILLIONAIRE?"); System.out.println("====================================="); System.out.println("Rules: Answer 15 questions. Use lifelines wisely."); System.out.println("Walk away anytime by typing 'W'.\n"); who wants to be a millionaire java game
public Question(String text, String[] options, int correctOption, int level) this.text = text; this.options = options; this.correctOption = correctOption; this.level = level; private boolean askQuestion(Question q) System
Enter choice (A/B/C/D), 'W' to walk away, 'L' for lifelines: C ššš"); System
public static void main(String[] args) MillionaireGame game = new MillionaireGame(); game.start();
public MillionaireGame() scanner = new Scanner(System.in); random = new Random(); currentLevel = 1; fiftyUsed = false; phoneUsed = false; audienceUsed = false; loadQuestions();
if (correct) if (currentLevel == 15) System.out.println("\nššš CONGRATULATIONS! YOU ARE A MILLIONAIRE! ššš"); System.out.println("You win $1,000,000!"); break; currentLevel++; else int prize = getGuaranteedPrize(); System.out.println("\nGame over! You leave with $" + prize); break; scanner.close();