Guest User

Untitled

a guest
May 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class MainGame {
  5.  
  6. static Question[] questions = new Question[15];
  7.  
  8. public static void main(String[] args) {
  9. loadQuestions(); //I found an error in my code were when I printed my questions it printed "null", I fixed that by calling the loadQuestions function.
  10.  
  11. Scanner kb = new Scanner(System.in);
  12. String userChoice = "", userAnswer = "", retry = "yes";
  13.  
  14.  
  15. System.out.println("Welcome to The Not Very Possible Quiz! ");
  16. System.out.println("By: Danny Gill");
  17.  
  18. do {
  19. System.out.println("Type In 'Play' to start playing, or type in 'Records' to see your high scores from previous games.");
  20. userChoice = (kb.nextLine().toLowerCase());
  21. } while (!(userChoice.equals("play") || userChoice.equals("records")));
  22.  
  23. if (userChoice.equals("records")) {
  24. System.out.println("High Scores:");
  25. } else if (userChoice.equals("play")) {
  26. System.out.println("Get Ready!");
  27. System.out.println(questions[10]);
  28. }
  29. }
  30.  
  31.  
  32. public static void loadQuestions() {
  33. questions[0] = new Question("Which concert is the cheapest?", "50 Cent", "Drake", "Rihanna", "2-Pac");
  34. questions[1] = new Question("Who was the first president of the USA?", "Donald Trump", "John Adams", "George Washington", "George W. Bush");
  35. questions[2] = new Question("Which country has the largest military?", "United States", "India", "China", "North Korea");
  36. questions[3] = new Question("In Hockey how many players are on the ice for each team?", "6", "5", "7", "4");
  37. questions[4] = new Question("What is Canada's national sport?", "Lacrosse", "Hockey", "Basketball", "Soccer");
  38. questions[5] = new Question("Who was the first prime minister of Canada?", "Lester B. Pearson", "Stephen Harper", "John A. Macdonald", "Alexander Mackenzie");
  39. questions[6] = new Question("What is the largest city in Canada?", "Calgary", "Toronto", "Montreal", "Vancouver");
  40. questions[7] = new Question("How many continents are there?", "5", "6", "7", "8");
  41. questions[8] = new Question("What is Pakistan's currency?", "Euro", "Dollar", "Rupee", "Yen");
  42. questions[9] = new Question("Who is currently the richest person on Earth?", "Bill Gates", "Elon Musk", "Jeff Bezos", "Mark Zuckerberg");
  43. questions[10] = new Question("Which planet is nearest to the sun?", "Earth", "Mercury", "Venus", "Saturn");
  44. questions[11] = new Question("Who invented Ferrari?", "Sergio Marchionne", "Endo Ferrari", "Enzo Ferrari", "Bill Ferrari");
  45. questions[12] = new Question("Who painted the Mona Lisa?", "Pablo Picasso", "Leonardo Who Cares", "Leonardo DiCaprio", "Leonardo Da Vinci");
  46. questions[13] = new Question("In what year was Google launched on the web?", "1998", "2000", "1997", "1990");
  47. questions[14] = new Question("How often are the olympics held?", "3 Years", "4 Years", "5 Years", "2 Years");
  48.  
  49. }
  50.  
  51.  
  52. }
Add Comment
Please, Sign In to add comment