Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
2.7 kB
2
Indexable
Never
case 3: {
							String contuniue = "y";
							while(contuniue.equalsIgnoreCase("y")) {
								String  contestant = participants[0].Name;
								int random_contestant = Millionaire.randomInt(1, participants.length);
								while(participants[random_contestant].getisPlayed() == false) {
									contestant = participants[random_contestant].Name;
									participants[random_contestant].isPlayed = true;
								}

								System.out.println();
								int money = 0;
								for (int i = 1; i < 6; i++) {
									difficulty = i;
									System.out.println("Contestant: " + contestant);
									System.out.println("-----------------------------------------------------------");
									String[] word_Cloud = Millionaire.generate_word_cloud(difficulty, questions);
									System.out.println("Word Cloud:\n\n");
									for (int j = 0; j < word_Cloud.length; j++) {
										if (i % 5 == 0) {
											System.out.println();
										}else {
											System.out.print(word_Cloud[j] + "\t");
										}
									}
									
									System.out.println();
									System.out.println("> Enter your selection: ");
									String selection = scanner.next();
									ew.clearConsole();
									
									
									int id = 0;
									id = Millionaire.get_question_id(difficulty, selection, questions);
									System.out.println("Q" + i + questions[id].getText());
									System.out.println("A) " + questions[id].getChoiceA());
									System.out.println("B) " + questions[id].getChoiceB());
									System.out.println("C) " + questions[id].getChoiceC());
									System.out.println("D) " + questions[id].getChoiceD());
									
									System.out.println("Enter your choice (E:Exit): ");
									thread.start();
									String answer = scanner.next();
									ew.clearConsole();
									if (answer.equalsIgnoreCase(questions[id].getCorrectAnswer())) {
										System.out.println();
										System.out.println("Correct Answer!");
										if (i == 5) {
											System.out.println("Congratulations, You won $1,000,000");
										}
										
									}else if (answer.equalsIgnoreCase("e")) {
										contuniue = "n";
										break;
										
									}else {
										if (i == 3 || i == 4) {
											money = 100;
											
										}else if (i == 5) {
											money = 500;
										}
										System.out.println("Wrong Answer, GAME OVER!");
										System.out.println("You won $" + money + ",000");
										System.out.println("Next contestan? (Y/N)");
										contuniue = scanner.next();
										ew.clearConsole();
										break;
									}
								}
								
							}
							
							

							
							
							
						}