Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.37 KB | None | 0 0
  1. static String[] Q = new String[30];{
  2. Q[0] = "Which of the following is a requirement in order to vote in a Canadian federal election?";
  3. Q[1] = "What major sporting event was held in Canada in 2010?";
  4. Q[2] = "Which of the following is not a province of Canada?";
  5. Q[3] = "Who was the first Prime Minister of Canada? ";
  6. Q[4] = "How many Oceans border Canada? ";
  7. Q[5] = "What is the status of Canada? ";
  8. Q[6] = "Which of the following islands is not part of Canada? ";
  9. Q[7] = "Which is the longest river in Canada? ";
  10. Q[8] = "Which Canadian province is the country’s largest producer and exporter of maple syrup? ";
  11. Q[9] = "Who donated the Stanley Cup to the National Hockey League? ";
  12. Q[10] = "Why did Ottawa establish the Mounted Police in 1873? ";
  13. Q[11] = "Which famous Canadian composed the Canadian national anthem? ";
  14. Q[12] = "Who is the Head of State of Canada? ";
  15. Q[13] = "Who after winning gold medal in 100 metres race in Seoul Olympics 1988 tested positive for drugs and was thrown out? ";
  16. Q[14] = "What university developed the world’s first anti-gravity suit? ";
  17. Q[15] = "O Canada! Our home and ______ land!";
  18. Q[16] = "Red and _____ are the national colours of Canada.";
  19. Q[17] = "The national animal of Canada is the ______ .";
  20. Q[18] = "Lacrosse is Canada’s national summer sport, _____ is the national winter sport.";
  21. Q[19] = "English and ______ are Canada’s national languages.";
  22. Q[20] = "The _____ leaf is featured on Canada’s national flag.";
  23. Q[21] = "Royal Canadian _______ Police are the federal police force of Canada.";
  24. Q[22] = "Canada’s newest territory is _______ .";
  25. Q[23] = "Canada celebrates its independence on ____ 1st every year.";
  26. Q[24] = "On one side of a quarter in The Queen, on the other side is a _____ .";
  27. Q[25] = "Wilfrid _______ is the man on the $5 bill.";
  28. Q[26] = "The name Canada originally meant _______ or settlement.";
  29. Q[27] = "The $2 coin of Canada is called a Toonie, the $1 coin is called a ______ .";
  30. Q[28] = "Mount _____ is the highest mountain in Canada.";
  31. Q[29] = "In Canada you may not publicly remove a ________ . ";}
  32.  
  33. static String[] optionA = new String[15];{
  34.  
  35. optionA[0]= " a) Your are at least 18 years old on election day";
  36. optionA[1]= " a) Summer Olympics ";
  37. optionA[2]= " a) Alberta ";
  38. optionA[3]= " a) Alexander Mackenzie ";
  39. optionA[4]= " a) 1";
  40. optionA[5]= " a) Republic";
  41. optionA[6]= " a) Greenland";
  42. optionA[7]= " a) St. Lawrence";
  43. optionA[8]= " a) Ontario";
  44. optionA[9]= " a) Bill Stanley";
  45. optionA[10]=" a) To perform equestrian shows";
  46. optionA[11]=" a) Ceiline Dion";
  47. optionA[12]=" a) President";
  48. optionA[13]=" a) Donovan Bailey";
  49. optionA[14]=" a) University of Toronto";}
  50.  
  51. static String[] optionB = new String [15];{
  52.  
  53. optionB[0]= " b) You are a Canadian citizen" ;
  54. optionB[1]= " b) Winter Olympics";
  55. optionB[2]= " b) British Columbia";
  56. optionB[3]= " b) John A. MacDonald";
  57. optionB[4]= " b) 2";
  58. optionB[5]= " b) Dominion";
  59. optionB[6]= " b) Baffin Island";
  60. optionB[7]= " b) Mackenzie";
  61. optionB[8]= " b) British Columbia";
  62. optionB[9]= " b) Governor General Lord Stanley";
  63. optionB[10]= " b) To pacify the West and negotiate with the Indians";
  64. optionB[11]= " b) Calixa Lavallee";
  65. optionB[12]= " b) Governor General";
  66. optionB[13]= " b) Ben Johnson";
  67. optionB[14]= " b) Simon Fraser University"; }
  68.  
  69. static String[] optionC = new String [15];{
  70.  
  71. optionC[0]= " c) You can prove your identity and address";
  72. optionC[1]= " c) World Cup ";
  73. optionC[2]= " c) Rhode Island ";
  74. optionC[3]= " c) Louis Riel ";
  75. optionC[4]= " c) 3 ";
  76. optionC[5]= " c) Kingdom ";
  77. optionC[6]= " c) Victoria Island ";
  78. optionC[7]= " c) Nelson ";
  79. optionC[8]= " c) Quebec ";
  80. optionC[9]= " c) Stanley Lord ";
  81. optionC[10]= " c) To arrest Louis Riel ";
  82. optionC[11]= " c) Bryan Adams ";
  83. optionC[12]= " c) Monarch of United Kingdom ";
  84. optionC[13]= " c) Carl Lewis ";
  85. optionC[14]= " c) University of British Columbia "; }
  86.  
  87.  
  88. static String[] optionD = new String [15];{
  89.  
  90.  
  91. optionD[0]= " d) All of the above";
  92. optionD[1]= " d) Commonwealth Games ";
  93. optionD[2]= " d) Quebec ";
  94. optionD[3]= " d) Wilfred Laurier ";
  95. optionD[4]= " d) 4 ";
  96. optionD[5]= " d) Commonwealth ";
  97. optionD[6]= " d) Prince Edward Island ";
  98. optionD[7]= " d) Fraser ";
  99. optionD[8]= " d) New Brunswick ";
  100. optionD[9]= " d) Stanley Bill ";
  101. optionD[10]= " d) To drive the Metis out of Canada ";
  102. optionD[11]= " d) Gordon Lightfoot ";
  103. optionD[12]= " d) Prime Minister ";
  104. optionD[13]= " d) Roger Bannister ";
  105. optionD[14]= " d) Queen’s University "; }
  106.  
  107. static String[] answer = new String [30];{
  108.  
  109. answer[0]= "D";
  110. answer[1]= "B";
  111. answer[2]= "C";
  112. answer[3]= "B";
  113. answer[4]= "C";
  114. answer[5]= "B";
  115. answer[6]= "A";
  116. answer[7]= "B";
  117. answer[8]= "C";
  118. answer[9]= "B";
  119. answer[10]= "B";
  120. answer[11]= "B";
  121. answer[12]= "C";
  122. answer[13]= "C";
  123. answer[14]= "A";
  124. answer[15]= "native";
  125. answer[16]= "white" ;
  126. answer[17]= "beaver" ;
  127. answer[18]= "hockey";
  128. answer[19]= "French";
  129. answer[20]= "maple";
  130. answer[21]= "Mounted";
  131. answer[22]= "Nunavut";
  132. answer[23]= "July";
  133. answer[24]= "moose";
  134. answer[25]= "Laurier";
  135. answer[26]= "village";
  136. answer[27]= "Loonie";
  137. answer[28]= "Logan";
  138. answer[29]= "Band-Aid";}
  139.  
  140.  
  141.  
  142. //first screen to be seen, asks user if they would like to open tutorial window
  143. public static void introScreen(){ //Main Programmer: Amarnath Parthiban
  144.  
  145. JPanel introScreen = new JPanel();
  146. introScreen.setLayout(null);
  147.  
  148. final JFrame introFrame = new JFrame("Welcome");
  149. introFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  150. introFrame.add(introScreen);
  151.  
  152. //text to be displayed on screen
  153. JLabel introTitle = new JLabel("So you think you're Canadian, eh?");
  154. introTitle.setFont(new Font("Calibri", Font.PLAIN, 20));
  155. introTitle.setBounds(5, 0, 500, 25);
  156.  
  157. JLabel introText1 = new JLabel("Welcome to the CIA Canadian trivia quiz.");
  158. introText1.setFont(new Font("Calibri", Font.PLAIN, 16));
  159. introText1.setBounds(15, 25, 500, 25);
  160.  
  161. JLabel introText2 = new JLabel("Would you like to take the tutorial?");
  162. introText2.setFont(new Font("Calibri", Font.PLAIN, 16));
  163. introText2.setBounds(25, 50, 500, 25);
  164.  
  165. //buttons for user input
  166. JButton yesTutorial = new JButton("YES");
  167. yesTutorial.setFont(new Font("Calibri", Font.PLAIN, 16));
  168. yesTutorial.setBounds(55, 75, 70, 30);
  169.  
  170. JButton noTutorial = new JButton("NO");
  171. noTutorial.setFont(new Font("Calibri", Font.PLAIN, 16));
  172. noTutorial.setBounds(165, 75, 70, 30);
  173.  
  174. introScreen.add(introTitle);
  175. introScreen.add(introText1);
  176. introScreen.add(introText2);
  177. introScreen.add(yesTutorial);
  178. introScreen.add(noTutorial);
  179.  
  180. introFrame.setSize(310,160);
  181. introFrame.setVisible(true);
  182.  
  183. yesTutorial.addActionListener(new ActionListener(){
  184.  
  185. public void actionPerformed(ActionEvent e){
  186.  
  187. //removes first window and opens the tutorial window
  188. introFrame.dispose();
  189. tutorial();
  190.  
  191. }
  192. });
  193.  
  194. noTutorial.addActionListener(new ActionListener(){
  195.  
  196. public void actionPerformed(ActionEvent e){
  197.  
  198. //removes first window and opens main quiz window
  199. introFrame.dispose();
  200. quiz();
  201.  
  202. }
  203. });
  204.  
  205. }
  206.  
  207. //static panel and frame to allow only one instance of the window to be open
  208. static JPanel mainQuiz = new JPanel();
  209. static JFrame mainFrame = new JFrame("CAI Quiz");
  210. static CardLayout card1 = new CardLayout();
  211.  
  212. //used to determine if the main quiz screen is open, defaulted to false for safety
  213. static boolean quizState = false;
  214.  
  215. public static void quiz(){ //Main Programmer: Amarnath Parthiban
  216.  
  217. mainQuiz.setLayout(card1);
  218. mainFrame.add(mainQuiz);
  219.  
  220. JPanel quiz = new JPanel();
  221. //allows use of (x,y) positions on JPanel
  222. quiz.setLayout(null);
  223.  
  224. //changes the state to inform that main quiz is open and other windows can be closed without ending the program
  225. quizState = true;
  226.  
  227. mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  228. mainQuiz.add(quiz, "a");
  229.  
  230. //title
  231. JLabel mainTitle = new JLabel("CAI CANADIAN QUIZ");
  232. mainTitle.setFont(new Font("Calibri", Font.PLAIN, 75));
  233. mainTitle.setBounds(190, 25, 700, 60);
  234.  
  235. //buttons for each question type and level including a random and tutorial button
  236. JButton MCLevel1 = new JButton("Multiple Choice Level 1");
  237. MCLevel1.setFont(new Font("Calibri", Font.PLAIN, 25));
  238. MCLevel1.setBounds(150, 200, 300, 100);
  239.  
  240. JButton MCLevel2 = new JButton("Multiple Choice Level 2");
  241. MCLevel2.setFont(new Font("Calibri", Font.PLAIN, 25));
  242. MCLevel2.setBounds(150, 350, 300, 100);
  243.  
  244. JButton MCLevel3 = new JButton("Multiple Choice Level 3");
  245. MCLevel3.setFont(new Font("Calibri", Font.PLAIN, 25));
  246. MCLevel3.setBounds(150, 500, 300, 100);
  247.  
  248. JButton FIBLevel1 = new JButton("Fill in The Blank Level 1");
  249. FIBLevel1.setFont(new Font("Calibri", Font.PLAIN, 25));
  250. FIBLevel1.setBounds(550, 200, 300, 100);
  251.  
  252. JButton FIBLevel2 = new JButton("Fill in The Blank Level 2");
  253. FIBLevel2.setFont(new Font("Calibri", Font.PLAIN, 25));
  254. FIBLevel2.setBounds(550, 350, 300, 100);
  255.  
  256. JButton FIBLevel3 = new JButton("Fill in The Blank Level 3");
  257. FIBLevel3.setFont(new Font("Calibri", Font.PLAIN, 25));
  258. FIBLevel3.setBounds(550, 500, 300, 100);
  259.  
  260. JButton random = new JButton("Random");
  261. random.setFont(new Font("Calibri", Font.PLAIN, 25));
  262. random.setBounds(350, 650, 300, 100);
  263.  
  264. JButton tutorial = new JButton("Tutorial");
  265. tutorial.setFont(new Font("Calibri", Font.PLAIN, 20));
  266. tutorial.setBounds(10, 650, 100, 100);
  267.  
  268. quiz.add(mainTitle);
  269. quiz.add(MCLevel1);
  270. quiz.add(MCLevel2);
  271. quiz.add(MCLevel3);
  272. quiz.add(FIBLevel1);
  273. quiz.add(FIBLevel2);
  274. quiz.add(FIBLevel3);
  275. quiz.add(random);
  276. quiz.add(tutorial);
  277.  
  278. mainFrame.setSize(1000,800);
  279. mainFrame.setVisible(true);
  280. card1.show(mainQuiz, "a");
  281.  
  282. MCLevel1.addActionListener(new ActionListener(){
  283.  
  284. public void actionPerformed(ActionEvent e){
  285.  
  286. MCLevel1();
  287.  
  288. }
  289. });
  290.  
  291. MCLevel2.addActionListener(new ActionListener(){
  292.  
  293. public void actionPerformed(ActionEvent e){
  294.  
  295. MCLevel2();
  296.  
  297. }
  298. });
  299.  
  300. MCLevel3.addActionListener(new ActionListener(){
  301.  
  302. public void actionPerformed(ActionEvent e){
  303.  
  304. MCLevel3();
  305.  
  306. }
  307. });
  308.  
  309. FIBLevel1.addActionListener(new ActionListener(){
  310.  
  311. public void actionPerformed(ActionEvent e){
  312.  
  313. FIBLevel1();
  314.  
  315. }
  316. });
  317.  
  318. FIBLevel2.addActionListener(new ActionListener(){
  319.  
  320. public void actionPerformed(ActionEvent e){
  321.  
  322. FIBLevel2();
  323.  
  324. }
  325. });
  326.  
  327. FIBLevel3.addActionListener(new ActionListener(){
  328.  
  329. public void actionPerformed(ActionEvent e){
  330.  
  331. FIBLevel3();
  332.  
  333. }
  334. });
  335.  
  336. tutorial.addActionListener(new ActionListener(){
  337.  
  338. public void actionPerformed(ActionEvent e){
  339.  
  340. //allows user to open tutorial when needed
  341. tutorial();
  342.  
  343. }
  344. });
  345.  
  346. }
  347.  
  348. static int x;
  349. static boolean state;
  350. static JLabel sessionScore = new JLabel("Session Score: N/A");
  351. static int questionsPerSession = 0;
  352. static int sessionCorrect = 0;
  353.  
  354. public static void MCLevel1(){ //Main Programmer: Amarnath Parthiban
  355.  
  356. questionsPerSession = 0;
  357.  
  358. final JPanel MC1 = new JPanel();
  359. MC1.setLayout(null);
  360.  
  361. mainQuiz.add(MC1, "b");
  362.  
  363. JLabel MC1Title = new JLabel("Multiple Choice Level 1");
  364. MC1Title.setFont(new Font("Calibri", Font.PLAIN, 50));
  365. MC1Title.setBounds(10, -30, 700, 120);
  366.  
  367. sessionScore.setFont(new Font("Calibri", Font.PLAIN, 25));
  368. sessionScore.setBounds(710, 650, 300, 120);
  369.  
  370. JButton MC1Back = new JButton("Return");
  371. MC1Back.setFont(new Font("Calibri", Font.PLAIN, 32));
  372. MC1Back.setBounds(5, 650, 300, 100);
  373.  
  374. JLabel question = new JLabel();
  375. JRadioButton A = new JRadioButton();
  376. JRadioButton B = new JRadioButton();
  377. JRadioButton C = new JRadioButton();
  378. JRadioButton D = new JRadioButton();
  379.  
  380. for (x = 0; x <= 5; x++){
  381.  
  382. MC1.repaint();
  383.  
  384. question.setText(Q[x]);
  385. question.setFont(new Font("Calibri", Font.PLAIN, 15));
  386. question.setBounds(110, 150, 270, 70);
  387.  
  388. A.setText(optionA[x]);
  389. A.setBounds(115, 240, 100, 10);
  390. A.setActionCommand("A");
  391.  
  392. B.setText(optionB[x]);
  393. B.setBounds(115, 255, 100, 10);
  394. B.setActionCommand("B");
  395.  
  396. C.setText(optionC[x]);
  397. C.setBounds(115, 270, 100, 10);
  398. C.setActionCommand("C");
  399.  
  400. D.setText(optionD[x]);
  401. D.setBounds(115, 285, 100, 10);
  402. D.setActionCommand("D");
  403.  
  404. ButtonGroup Q1Group = new ButtonGroup();
  405. Q1Group.add(A);
  406. Q1Group.add(B);
  407. Q1Group.add(C);
  408. Q1Group.add(D);
  409.  
  410. JButton submit = new JButton("Submit");
  411. submit.setFont(new Font("Calibri", Font.PLAIN, 32));
  412. submit.setBounds(205, 450, 300, 100);
  413.  
  414. MC1.add(MC1Title);
  415. MC1.add(question);
  416. MC1.add(MC1Back);
  417. MC1.add(A);
  418. MC1.add(B);
  419. MC1.add(C);
  420. MC1.add(D);
  421. MC1.add(sessionScore);
  422. MC1.add(submit);
  423.  
  424. card1.show(mainQuiz, "b");
  425.  
  426. MC1Back.addActionListener(new ActionListener(){
  427.  
  428. public void actionPerformed(ActionEvent e){
  429.  
  430. quiz();
  431.  
  432. }
  433. });
  434.  
  435. A.addActionListener(new ActionListener(){
  436.  
  437. public void actionPerformed(ActionEvent e){
  438.  
  439. state = result("A");
  440.  
  441. }
  442. });
  443.  
  444. B.addActionListener(new ActionListener(){
  445.  
  446. public void actionPerformed(ActionEvent e){
  447.  
  448. state = result("B");
  449.  
  450. }
  451. });
  452.  
  453. C.addActionListener(new ActionListener(){
  454.  
  455. public void actionPerformed(ActionEvent e){
  456.  
  457. state = result("C");
  458.  
  459. }
  460. });
  461.  
  462.  
  463. D.addActionListener(new ActionListener(){
  464.  
  465. public void actionPerformed(ActionEvent e){
  466.  
  467. state = result("D");
  468.  
  469. }
  470. });
  471.  
  472. questionsPerSession++;
  473. score();
  474.  
  475. }
  476. }
  477.  
  478. public static boolean result(String userAnswer){
  479.  
  480. if (userAnswer.equals(answer[x])){
  481. sessionCorrect++;
  482. return true;
  483. }
  484. else
  485. return false;
  486.  
  487. }
  488.  
  489. public static void sessionScoreCalculate(){
  490.  
  491. sessionScore.setText("Session Score: " + (sessionCorrect/questionsPerSession) );
  492.  
  493.  
  494. }
  495.  
  496. public static void MCLevel2(){ //Main Programmer: Amarnath Parthiban
  497.  
  498. JPanel MC2 = new JPanel();
  499. MC2.setLayout(null);
  500.  
  501. mainQuiz.add(MC2, "c");
  502.  
  503. JLabel MC1Title = new JLabel("Score");
  504. MC1Title.setFont(new Font("Calibri", Font.PLAIN, 75));
  505. MC1Title.setBounds(380, 25, 700, 120);
  506.  
  507. JLabel scoreDescription = new JLabel("<html>Your score, displayed as a percentage, will directly repersent the amount of question you answerd correnctl compared to the total amount of questions you've answered."
  508. + " On the main menu your score will be displayed once as your overall score."
  509. + " When in a session your total score as well as your session score will be visible."
  510. + " These scores will automaticly updated as you continue on with your session."
  511. + " If you choose to end session prematurely (before you have answered all the questions) your session pregress will not be saved and will not be added to your total score. </html>");
  512. scoreDescription.setFont(new Font("Calibri", Font.PLAIN, 25));
  513. scoreDescription.setBounds(150, 50, 700, 500);
  514.  
  515. JButton scoreBack = new JButton("Return");
  516. scoreBack.setFont(new Font("Calibri", Font.PLAIN, 32));
  517. scoreBack.setBounds(350, 600, 300, 100);
  518.  
  519. MC2.add(MC1Title);
  520. MC2.add(scoreDescription);
  521. MC2.add(scoreBack);
  522.  
  523. card1.show(mainQuiz, "c");
  524.  
  525. scoreBack.addActionListener(new ActionListener(){
  526.  
  527. public void actionPerformed(ActionEvent e){
  528.  
  529. quiz();
  530.  
  531. }
  532. });
  533.  
  534. }
  535.  
  536. public static void MCLevel3(){ //Main Programmer: Amarnath Parthiban
  537.  
  538. JPanel MC3 = new JPanel();
  539. MC3.setLayout(null);
  540.  
  541. mainQuiz.add(MC3, "d");
  542.  
  543. JLabel MC1Title = new JLabel("Score");
  544. MC1Title.setFont(new Font("Calibri", Font.PLAIN, 75));
  545. MC1Title.setBounds(380, 25, 700, 120);
  546.  
  547. JLabel scoreDescription = new JLabel("<html>Your score, displayed as a percentage, will directly repersent the amount of question you answerd correnctl compared to the total amount of questions you've answered."
  548. + " On the main menu your score will be displayed once as your overall score."
  549. + " When in a session your total score as well as your session score will be visible."
  550. + " These scores will automaticly updated as you continue on with your session."
  551. + " If you choose to end session prematurely (before you have answered all the questions) your session pregress will not be saved and will not be added to your total score. </html>");
  552. scoreDescription.setFont(new Font("Calibri", Font.PLAIN, 25));
  553. scoreDescription.setBounds(150, 50, 700, 500);
  554.  
  555. JButton scoreBack = new JButton("Return");
  556. scoreBack.setFont(new Font("Calibri", Font.PLAIN, 32));
  557. scoreBack.setBounds(350, 600, 300, 100);
  558.  
  559. MC3.add(MC1Title);
  560. MC3.add(scoreDescription);
  561. MC3.add(scoreBack);
  562.  
  563. card1.show(mainQuiz, "d");
  564.  
  565. scoreBack.addActionListener(new ActionListener(){
  566.  
  567. public void actionPerformed(ActionEvent e){
  568.  
  569. quiz();
  570.  
  571. }
  572. });
  573.  
  574. }
  575.  
  576. public static void FIBLevel1(){ //Main Programmer: Amarnath Parthiban
  577.  
  578. JPanel FIB1 = new JPanel();
  579. FIB1.setLayout(null);
  580.  
  581. mainQuiz.add(FIB1, "e");
  582.  
  583. JLabel MC1Title = new JLabel("Score");
  584. MC1Title.setFont(new Font("Calibri", Font.PLAIN, 75));
  585. MC1Title.setBounds(380, 25, 700, 120);
  586.  
  587. JLabel scoreDescription = new JLabel("<html>Your score, displayed as a percentage, will directly repersent the amount of question you answerd correnctl compared to the total amount of questions you've answered."
  588. + " On the main menu your score will be displayed once as your overall score."
  589. + " When in a session your total score as well as your session score will be visible."
  590. + " These scores will automaticly updated as you continue on with your session."
  591. + " If you choose to end session prematurely (before you have answered all the questions) your session pregress will not be saved and will not be added to your total score. </html>");
  592. scoreDescription.setFont(new Font("Calibri", Font.PLAIN, 25));
  593. scoreDescription.setBounds(150, 50, 700, 500);
  594.  
  595. JButton scoreBack = new JButton("Return");
  596. scoreBack.setFont(new Font("Calibri", Font.PLAIN, 32));
  597. scoreBack.setBounds(350, 600, 300, 100);
  598.  
  599. FIB1.add(MC1Title);
  600. FIB1.add(scoreDescription);
  601. FIB1.add(scoreBack);
  602.  
  603. card1.show(mainQuiz, "e");
  604.  
  605. scoreBack.addActionListener(new ActionListener(){
  606.  
  607. public void actionPerformed(ActionEvent e){
  608.  
  609. quiz();
  610.  
  611. }
  612. });
  613.  
  614. }
  615.  
  616. public static void FIBLevel2(){ //Main Programmer: Amarnath Parthiban
  617.  
  618. JPanel FIB2 = new JPanel();
  619. FIB2.setLayout(null);
  620.  
  621. mainQuiz.add(FIB2, "f");
  622.  
  623. JLabel MC1Title = new JLabel("Score");
  624. MC1Title.setFont(new Font("Calibri", Font.PLAIN, 75));
  625. MC1Title.setBounds(380, 25, 700, 120);
  626.  
  627. JLabel scoreDescription = new JLabel("<html>Your score, displayed as a percentage, will directly repersent the amount of question you answerd correnctl compared to the total amount of questions you've answered."
  628. + " On the main menu your score will be displayed once as your overall score."
  629. + " When in a session your total score as well as your session score will be visible."
  630. + " These scores will automaticly updated as you continue on with your session."
  631. + " If you choose to end session prematurely (before you have answered all the questions) your session pregress will not be saved and will not be added to your total score. </html>");
  632. scoreDescription.setFont(new Font("Calibri", Font.PLAIN, 25));
  633. scoreDescription.setBounds(150, 50, 700, 500);
  634.  
  635. JButton scoreBack = new JButton("Return");
  636. scoreBack.setFont(new Font("Calibri", Font.PLAIN, 32));
  637. scoreBack.setBounds(350, 600, 300, 100);
  638.  
  639. FIB2.add(MC1Title);
  640. FIB2.add(scoreDescription);
  641. FIB2.add(scoreBack);
  642.  
  643. card1.show(mainQuiz, "f");
  644.  
  645. scoreBack.addActionListener(new ActionListener(){
  646.  
  647. public void actionPerformed(ActionEvent e){
  648.  
  649. quiz();
  650.  
  651. }
  652. });
  653.  
  654. }
  655.  
  656. public static void FIBLevel3(){ //Main Programmer: Amarnath Parthiban
  657.  
  658. JPanel FIB3 = new JPanel();
  659. FIB3.setLayout(null);
  660.  
  661. mainQuiz.add(FIB3, "g");
  662.  
  663. JLabel MC1Title = new JLabel("Score");
  664. MC1Title.setFont(new Font("Calibri", Font.PLAIN, 75));
  665. MC1Title.setBounds(380, 25, 700, 120);
  666.  
  667. JLabel scoreDescription = new JLabel("<html>Your score, displayed as a percentage, will directly repersent the amount of question you answerd correnctl compared to the total amount of questions you've answered."
  668. + " On the main menu your score will be displayed once as your overall score."
  669. + " When in a session your total score as well as your session score will be visible."
  670. + " These scores will automaticly updated as you continue on with your session."
  671. + " If you choose to end session prematurely (before you have answered all the questions) your session pregress will not be saved and will not be added to your total score. </html>");
  672. scoreDescription.setFont(new Font("Calibri", Font.PLAIN, 25));
  673. scoreDescription.setBounds(150, 50, 700, 500);
  674.  
  675. JButton scoreBack = new JButton("Return");
  676. scoreBack.setFont(new Font("Calibri", Font.PLAIN, 75));
  677. scoreBack.setBounds(350, 600, 300, 100);
  678.  
  679. FIB3.add(MC1Title);
  680. FIB3.add(scoreDescription);
  681. FIB3.add(scoreBack);
  682.  
  683. card1.show(mainQuiz, "g");
  684.  
  685. scoreBack.addActionListener(new ActionListener(){
  686.  
  687. public void actionPerformed(ActionEvent e){
  688.  
  689. quiz();
  690.  
  691. }
  692. });
  693.  
  694. }
  695.  
  696. //static panel and frame to allow only one instance of the window to be open
  697. static JPanel mainTutorial = new JPanel();
  698. static JFrame tutorialFrame = new JFrame("Tutorial");
  699.  
  700. //allows for multiple JPanels on one JFrame
  701. static CardLayout card2 = new CardLayout();
  702.  
  703. public static void tutorial(){ //Main Programmer: Amarnath Parthiban
  704.  
  705. mainTutorial.setLayout(card2);
  706. tutorialFrame.add(mainTutorial);
  707.  
  708. //additional panel to set on top and interchange between other panels
  709. JPanel tutorial = new JPanel();
  710. tutorial.setLayout(null);
  711.  
  712. mainTutorial.add(tutorial, "one");
  713.  
  714. //determine if the tutorial window needs to stop the program or not
  715. if (quizState == true)
  716. tutorialFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  717. else
  718. tutorialFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  719.  
  720. //title for the panel
  721. JLabel tutorialTitle = new JLabel("Tutorial");
  722. tutorialTitle.setFont(new Font("Calibri", Font.PLAIN, 75));
  723. tutorialTitle.setBounds(380, 25, 700, 60);
  724.  
  725. //buttons for each topic, including a quiz button
  726. JButton score = new JButton("Score");
  727. score.setFont(new Font("Calibri", Font.PLAIN, 32));
  728. score.setBounds(150, 200, 300, 100);
  729.  
  730. JButton level = new JButton("Level");
  731. level.setFont(new Font("Calibri", Font.PLAIN, 32));
  732. level.setBounds(150, 400, 300, 100);
  733.  
  734. JButton type = new JButton("Type");
  735. type.setFont(new Font("Calibri", Font.PLAIN, 32));
  736. type.setBounds(550, 200, 300, 100);
  737.  
  738. JButton answering = new JButton("Answering");
  739. answering.setFont(new Font("Calibri", Font.PLAIN, 32));
  740. answering.setBounds(550, 400, 300, 100);
  741.  
  742. JButton main = new JButton("QUIZ SCREEN");
  743. main.setFont(new Font("Calibri", Font.PLAIN, 32));
  744. main.setBounds(350, 600, 300, 100);
  745.  
  746. tutorial.add(tutorialTitle);
  747. tutorial.add(score);
  748. tutorial.add(level);
  749. tutorial.add(type);
  750. tutorial.add(answering);
  751. tutorial.add(main);
  752.  
  753. tutorialFrame.setSize(1000,800);
  754. tutorialFrame.setVisible(true);
  755.  
  756. //displays the home tutorial panel
  757. card2.show(mainTutorial, "one");
  758.  
  759. //calling methods for each of the topics depending on button pushed
  760. score.addActionListener(new ActionListener(){
  761.  
  762. public void actionPerformed(ActionEvent e){
  763.  
  764. score();
  765.  
  766. }
  767. });
  768.  
  769. level.addActionListener(new ActionListener(){
  770.  
  771. public void actionPerformed(ActionEvent e){
  772.  
  773. level();
  774.  
  775. }
  776. });
  777.  
  778. type.addActionListener(new ActionListener(){
  779.  
  780. public void actionPerformed(ActionEvent e){
  781.  
  782. type();
  783.  
  784. }
  785. });
  786.  
  787. answering.addActionListener(new ActionListener(){
  788.  
  789. public void actionPerformed(ActionEvent e){
  790.  
  791. answering();
  792.  
  793. }
  794. });
  795.  
  796. main.addActionListener(new ActionListener(){
  797.  
  798. public void actionPerformed(ActionEvent e){
  799.  
  800. //open the quiz window, make the tutoral window disposible without ending the program
  801. tutorialFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  802. quiz();
  803.  
  804. }
  805. });
  806.  
  807. }
  808.  
  809. //START: methods used by the tutorial screen exclusively
  810.  
  811. //each method contains a title, a brief description and a button to return to the main tutorial screen
  812. public static void score(){ //Main Programmer: Amarnath Parthiban
  813.  
  814. JPanel scoreTutorial = new JPanel();
  815. scoreTutorial.setLayout(null);
  816.  
  817. mainTutorial.add(scoreTutorial, "two");
  818.  
  819. JLabel scoreTitle = new JLabel("Score");
  820. scoreTitle.setFont(new Font("Calibri", Font.PLAIN, 75));
  821. scoreTitle.setBounds(380, 25, 700, 120);
  822.  
  823. JLabel scoreDescription = new JLabel("<html>Your score, displayed as a percentage, will directly repersent the amount of question you answerd correnctl compared to the total amount of questions you've answered."
  824. + " On the main menu your score will be displayed once as your overall score."
  825. + " When in a session your total score as well as your session score will be visible."
  826. + " These scores will automaticly updated as you continue on with your session."
  827. + " If you choose to end session prematurely (before you have answered all the questions) your session pregress will not be saved and will not be added to your total score. </html>");
  828. scoreDescription.setFont(new Font("Calibri", Font.PLAIN, 25));
  829. scoreDescription.setBounds(150, 50, 700, 500);
  830.  
  831. JButton scoreBack = new JButton("Return");
  832. scoreBack.setFont(new Font("Calibri", Font.PLAIN, 32));
  833. scoreBack.setBounds(350, 600, 300, 100);
  834.  
  835. scoreTutorial.add(scoreTitle);
  836. scoreTutorial.add(scoreDescription);
  837. scoreTutorial.add(scoreBack);
  838.  
  839. card2.show(mainTutorial, "two");
  840.  
  841. scoreBack.addActionListener(new ActionListener(){
  842.  
  843. public void actionPerformed(ActionEvent e){
  844.  
  845. tutorial();
  846.  
  847. }
  848. });
  849.  
  850. }
  851.  
  852. public static void level(){ //Main Programmer: Amarnath Parthiban
  853.  
  854. JPanel levelTutorial = new JPanel();
  855. levelTutorial.setLayout(null);
  856.  
  857. mainTutorial.add(levelTutorial, "three");
  858.  
  859. JLabel levelTitle = new JLabel("Level");
  860. levelTitle.setFont(new Font("Calibri", Font.PLAIN, 75));
  861. levelTitle.setBounds(380, 25, 700, 120);
  862.  
  863. JLabel levelDescription = new JLabel("<html> Every type has 3 levels; easy, medium and hard."
  864. + " The easy questions are basic questions, the answers to these questions should come from the top of you head."
  865. + " Medium-leveled questions modertaley difficult. They require some background knowledge of Canada."
  866. + " In each level, there will be five questions."
  867. + " After answering a new one , under the same level will appear. "
  868. + " The hard questions have a high difficulty rating. You will need to know every inch of Canadian history, geography and culture."
  869. + " Don't worry about the level. I think you can do it. </html>");
  870. levelDescription.setFont(new Font("Calibri", Font.PLAIN, 25));
  871. levelDescription.setBounds(150, 50, 700, 500);
  872.  
  873. JButton levelBack = new JButton("Return");
  874. levelBack.setFont(new Font("Calibri", Font.PLAIN, 32));
  875. levelBack.setBounds(350, 600, 300, 100);
  876.  
  877. levelTutorial.add(levelTitle);
  878. levelTutorial.add(levelDescription);
  879. levelTutorial.add(levelBack);
  880.  
  881. card2.show(mainTutorial, "three");
  882.  
  883. levelBack.addActionListener(new ActionListener(){
  884.  
  885. public void actionPerformed(ActionEvent e){
  886.  
  887. tutorial();
  888.  
  889. }
  890. });
  891.  
  892. }
  893.  
  894. public static void type(){ //Main Programmer: Amarnath Parthiban
  895.  
  896. JPanel typeTutorial = new JPanel();
  897. typeTutorial.setLayout(null);
  898.  
  899. mainTutorial.add(typeTutorial, "four");
  900.  
  901. JLabel typeTitle = new JLabel("Type");
  902. typeTitle.setFont(new Font("Calibri", Font.PLAIN, 75));
  903. typeTitle.setBounds(380, 25, 700, 120);
  904.  
  905. JLabel typeDescription = new JLabel("<html>In this quiz, there are three types of questions; multiple choice, fill in the blanks and random."
  906. + " If you choose a multiple choice question the options will be given to you along with the question ."
  907. + " The fill in the blanks will require you to type in the missing word of the phrase."
  908. + " Random is a type where the computer chooses a question type for you and."
  909. + " If you choose to end session prematurely (before you have answered all the questions) your session pregress will not be saved and will not be added to your total score. </html>");
  910. typeDescription.setFont(new Font("Calibri", Font.PLAIN, 25));
  911. typeDescription.setBounds(150, 50, 700, 500);
  912.  
  913. JButton typeBack = new JButton("Return");
  914. typeBack.setFont(new Font("Calibri", Font.PLAIN, 32));
  915. typeBack.setBounds(350, 600, 300, 100);
  916.  
  917. typeTutorial.add(typeTitle);
  918. typeTutorial.add(typeDescription);
  919. typeTutorial.add(typeBack);
  920.  
  921. card2.show(mainTutorial, "four");
  922.  
  923. typeBack.addActionListener(new ActionListener(){
  924.  
  925. public void actionPerformed(ActionEvent e){
  926.  
  927. tutorial();
  928.  
  929. }
  930. });
  931.  
  932. }
  933.  
  934. public static void answering(){ //Main Programmer: Amarnath Parthiban
  935.  
  936. JPanel answeringTutorial = new JPanel();
  937. answeringTutorial.setLayout(null);
  938.  
  939. mainTutorial.add(answeringTutorial, "five");
  940.  
  941. JLabel answeringTitle = new JLabel("Answering");
  942. answeringTitle.setFont(new Font("Calibri", Font.PLAIN, 75));
  943. answeringTitle.setBounds(320, 25, 700, 120);
  944.  
  945. JLabel answeringDescription = new JLabel("<html> Answering a question varies by it's type."
  946. + " For the multiple choice questions, your answer will be taken in once you click on one of the options."
  947. + " For the fill in the blank questions will give you a box to type in your answer."
  948. + " Remember, this quiz case sensitive."
  949. + " Make sure to use captials only on pronouns and correct casing (beggining of a sentence).");
  950. answeringDescription.setFont(new Font("Calibri", Font.PLAIN, 25));
  951. answeringDescription.setBounds(150, 50, 700, 500);
  952.  
  953. JButton answeringBack = new JButton("Return");
  954. answeringBack.setFont(new Font("Calibri", Font.PLAIN, 32));
  955. answeringBack.setBounds(350, 600, 300, 100);
  956.  
  957. answeringTutorial.add(answeringTitle);
  958. answeringTutorial.add(answeringDescription);
  959. answeringTutorial.add(answeringBack);
  960.  
  961. card2.show(mainTutorial, "five");
  962.  
  963. answeringBack.addActionListener(new ActionListener(){
  964.  
  965. public void actionPerformed(ActionEvent e){
  966.  
  967. tutorial();
  968.  
  969. }
  970. });
  971.  
  972. }
  973. //END: methods used by the tutorial screen exclusively
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement