Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.18 KB | None | 0 0
  1. import java.awt.*;
  2.  
  3. import hsa_ufa.Console;
  4.  
  5.  
  6. public class DavisChypyhaICS3UFinalProject {
  7.  
  8. static Console c; // The output console
  9. static int stage = 0;
  10. static String [] levels =
  11. {"1. $ 100",
  12. "2. $ 200",
  13. "3. $ 300",
  14. "4. $ 500",
  15. "5. $ 1 000",
  16. "6. $ 2 000",
  17. "7. $ 4 000",
  18. "8. $ 8 000",
  19. "9. $ 16 000",
  20. "10. $ 32 000",
  21. "11. $ 64 000",
  22. "12. $ 125 000",
  23. "13. $ 250 000",
  24. "14. $ 500 000",
  25. "15. $ 1 000 000"
  26. };
  27. static String[] choices = new String[4];
  28. static String rtAns[][]={{
  29. "25",
  30. "Wayne Gretzky",
  31. "1917",
  32. "3",
  33. "QMJHL, OHL and WHL",
  34. "Jonathon Toews",
  35. "Evgeni Nabokov",
  36. "2003-04",
  37. "215",
  38. "4",
  39. "Carolina Hurricanes",
  40. "Mike Green",
  41. "McJesus",
  42. "Colorado Avalanche",
  43. "Tiger Williams"},{
  44. "New York Knicks",
  45. "Wilt Chamberlain",
  46. "Stephen Curry",
  47. "Jumpshot",
  48. "Chris Ford",
  49. "LeBron James",
  50. "Los Angelos Lakers",
  51. "Meadowlark Lemon",
  52. "'Pistol' Pete Maravich",
  53. "Britney Griner",
  54. "0",
  55. "Shaquil O'Neil",
  56. "Earvin 'Magic' Johnson",
  57. "Los Angelos Lakers",
  58. "Michael Jordan"},{
  59. "Jack Nicklaus and Arnold Palmer",
  60. "0",
  61. "The Honor",
  62. "Leslie Nielsen",
  63. "The Masters",
  64. "Jack Nicklaus",
  65. "The Masters",
  66. "Tom Watson",
  67. "Chi Chi Rodriguez",
  68. "Arnold Palmer",
  69. "Jack Nicklaus",
  70. "Jack Nicklaus",
  71. "The Masters",
  72. "Annika Sorenstam",
  73. "Nick Price"}};
  74. static String wgAns1[][]= {{
  75. "22",
  76. "Gordie Howe",
  77. "1923",
  78. "8",
  79. "OHl, GTHL, AHL",
  80. "Ari Davis",
  81. "Aviel Moran",
  82. "2008-09",
  83. "200",
  84. "6",
  85. "Winnipeg Jets",
  86. "Chase Chyphya",
  87. "Sid the kid",
  88. "New York Islanders",
  89. "Zack Mindel"},{
  90. "Toronto Raptors",
  91. "Kyle Lowry",
  92. "Draymond Green",
  93. "Hookshot",
  94. "Larry Bird",
  95. "Danny Green",
  96. "Golden State Warriors",
  97. "Vince Carter",
  98. "Mike Russel",
  99. "Larry Tanenbaum",
  100. "3",
  101. "Mo Bomba",
  102. "Kobe Bryant",
  103. "San Antonio Spurs",
  104. "Scottie Pippen",
  105. "Tiger Woods and Phil Mickelson"},{
  106. "15",
  107. "The Tribute",
  108. "Liam Nieson",
  109. "The Open",
  110. "Arnold Palmer",
  111. "The Open",
  112. "Emma Watson",
  113. "Aaron Rodriguez",
  114. "Jackie Chan",
  115. "Chance the Rapper",
  116. "Big Sean",
  117. "The Championship",
  118. "Anika Boron",
  119. "Jack Price"}};
  120. static String wgAns2[][]= {{
  121.  
  122. "20",
  123. "Bobby Hull",
  124. "1904",
  125. "2",
  126. "QMJHL, CHL, WHL",
  127. "Patrick Kane",
  128. "Bryan Little",
  129. "1999-2000",
  130. "196",
  131. "7",
  132. "Tampa Bay Lightning",
  133. "Josh Green",
  134. "Ovechkin",
  135. "Atlanta Thrashers",
  136. "Nail Yakopov"},{
  137. "Milwaukie Bucks",
  138. "Meta World Peace",
  139. "Dwayne Wade",
  140. "Granny Shot",
  141. "Doug Ford",
  142. "Lonzo Ball",
  143. "Ans2",
  144. "Ans2",
  145. "Ans2",
  146. "Ans2",
  147. "Ans2",
  148. "Ans2",
  149. "Ans2",
  150. "Ans2",
  151. "Ans2"},{
  152. "Ans2",
  153. "Ans2",
  154. "Ans2",
  155. "Ans2",
  156. "Ans2",
  157. "Ans2",
  158. "Ans2",
  159. "Ans2",
  160. "Ans2",
  161. "Ans2",
  162. "Ans2",
  163. "Ans2",
  164. "Ans2",
  165. "Ans2",
  166. "Ans2"}};
  167.  
  168. static String wgAns3[][] = {{
  169. "Ans3",
  170. "Ans3",
  171. "Ans3",
  172. "Ans3",
  173. "Ans3",
  174. "Ans3",
  175. "Ans3",
  176. "Ans3",
  177. "Ans3",
  178. "Ans3",
  179. "Ans3",
  180. "Ans3",
  181. "Ans3",
  182. "Ans3",
  183. "Ans3"},{
  184. "Ans3",
  185. "Ans3",
  186. "Ans3",
  187. "Ans3",
  188. "Ans3",
  189. "Ans3",
  190. "Ans3",
  191. "Ans3",
  192. "Ans3",
  193. "Ans3",
  194. "Ans3",
  195. "Ans3",
  196. "Ans3",
  197. "Ans3",
  198. "Ans3"},{
  199. "Ans3",
  200. "Ans3",
  201. "Ans3",
  202. "Ans3",
  203. "Ans3",
  204. "Ans3",
  205. "Ans3",
  206. "Ans3",
  207. "Ans3",
  208. "Ans3",
  209. "Ans3",
  210. "Ans3",
  211. "Ans3",
  212. "Ans3",
  213. "Ans3"}};
  214. static int tempN[] = new int[4];
  215. public static int category () {
  216.  
  217. int choice1 = c.readInt();
  218. c.setCursor(11, 10);
  219. return (c.readInt() - 1);
  220. }
  221.  
  222.  
  223.  
  224. public static void lvl (){
  225. for (int i=0; i<15; i++) {
  226. int x = 713;
  227. if (i >= 9) {
  228. x = 702;
  229. }
  230. if(i==stage)c.setColor(Color.green);
  231. else c.setColor(new Color(210,102,4));
  232. c.drawString (levels [i], x, 403-i*25);
  233. }
  234. }
  235. public static String[] randomizeChoices (int ct, int qst){
  236. String[] tempC = new String[4];
  237. tempN = new int[4];
  238.  
  239. tempN[0] = (int)(Math.random()*4);
  240.  
  241.  
  242. tempN[1] = (int)(Math.random()*4);
  243. while(tempN[1]==tempN[0])tempN[1] = (int)(Math.random()*4);;
  244.  
  245.  
  246. tempN[2] = (int)(Math.random()*4);
  247. while(tempN[2]==tempN[0]||tempN[2]==tempN[1])tempN[2] = (int)(Math.random()*4);;
  248.  
  249.  
  250. tempN[3] = (int)(Math.random()*4);
  251. while(tempN[3]==tempN[0]||tempN[3]==tempN[1]||tempN[3]==tempN[2])tempN[3] = (int)(Math.random()*4);;
  252.  
  253.  
  254. tempC[tempN[0]]=rtAns[ct][qst];
  255. tempC[tempN[1]]=wgAns1[ct][qst];
  256. tempC[tempN[2]]=wgAns2[ct][qst];
  257. tempC[tempN[3]]=wgAns3[ct][qst];
  258.  
  259. return tempC;}
  260. public static void main (String[] args) throws InterruptedException
  261. {
  262. c = new Console (850, 680);
  263.  
  264. //variables
  265. int hockey = 0;
  266. int ball = 0;
  267. int golf = 0;
  268. int cat = 0;
  269. int quest = 0;
  270. int o=2;
  271.  
  272. Image logo = Toolkit.getDefaultToolkit().getImage("logo.png");
  273.  
  274.  
  275.  
  276.  
  277. String [][] board = new String[3][15];
  278. board [0][0] = "How old was Wayne Gretzky when he scored his 500th career goal?";//25
  279. board [0][1] = "Which former player was known as “The Great One”?";
  280. board [0][2] = "In what year did the NHL begin?";//1917
  281. board [0][3] = "How many NHL teams have their full names on their logos (no abbreviations)?";//3
  282. board [0][4] = "Which three sub-leagues make up the Canadian Hockey League?";//QM,OH,WH
  283. board [0][5] = "Who holds the record for youngest player to join the “Triple Gold Club”?";//tOEWS
  284. board [0][6] = "Who was the first European-born goaltender to score a goal?";//Evgeni Nabokov
  285. board [0][7] = "What was the last season the NHL did not have a salary cap?";//2003-04
  286. board [0][8] = "What’s the record for most points in a single NHL season?";//215
  287. board [0][9] = "In a preliminary-round game of the 2014 Winter Olympics between the United States and Russia, how many shootout goals did T.J. Oshie score, leading his team to a 3-2 victory?"; //4
  288. board [0][10] = "Who is the most recent Stanley Cup winner that missed the playoffs in the season before and after their championship?";//hurricanes
  289. board [0][11] = "Who holds the record for longest NHL goal-scoring streak as a defenseman?";//Mike Green
  290. board [0][12] = "Which player holds the record for youngest captain in NHL history?";//Mcd
  291. board [0][13] = "Paul Kariya and Teemu Selanne were teammates with the Anaheim Mighty Ducks for several seasons. But, which other team did they once play together on for one season?";//Avalanche
  292. board [0][14] = "Which player is the all-time career penalty minute’s leader with a total of 3,966?";//tiger williams
  293. board [1][0] = "What team won the very first NBA game?";//knicks
  294. board [1][1] = "What NBA player scored 100 points on March 2, 1962?";//chamberlain
  295. board [1][2] = "Who was the first player in NBA history to be elected league MVP by a unanimous vote?";//curry
  296. board [1][3] = "What new kind of shot did Joe Fulks score a record 63 points with in one game in 1949?";//jumpshot
  297. board [1][4] = "Who scored the first three-point basket in NBA history?";//chris ford
  298. board [1][5] = "Who was the youngest player to score 10,000 points in the NBA?";//lebron
  299. board [1][6] = "What team owns the longest winning streak in NBA history?";//lakers
  300. board [1][7] = "What player was known as the 'Clown Prince' of the Harlem Globetrotters?";//Meadowlark Lemon
  301. board [1][8] = "Who is the all-time leading scorer in men's college basketball?";//"Pistol" Pete Maravich
  302. board [1][9] = "Who was the first WNBA player to dunk in a playoff game?";//Britney Griner
  303. board [1][10] = "How many games did Wilt Chamberlain foul out of during his 14 year NBA career?";//0
  304. board [1][11] = "What player won All-Star Game MVP, NBA MVP, and NBA Finals MVP awards in 2000?";//shaq
  305. board [1][12] = "What NBA player retired unexpectedly on November 7, 1991?";//Earvin "Magic" Johnson
  306. board [1][13] = "What team did Wilt Chamberlain finish his NBA career with?";//lakers
  307. board [1][14] = "Who won the Nestle Crunch Slam Dunk Contest on February 6, 1988?";//jordan
  308. board [2][0] = "What two golfers led the PGA in earnings three seasons each in the 1960s?";//Jack Nicklaus and Arnold Palmer.
  309. board [2][1] = "What's a scratch golfer's handicap?";//zero
  310. board [2][2] = "What's a golfer said to have if he is entitled to tee off first?";//The Honor
  311. board [2][3] = "What comic actor scored huge sales with his Bad Golf Made Easy instructional videos?";//Leslie Nielsen
  312. board [2][4] = "What Grand Slam golf tournament has the most club housers sipping mint juleps?";// The Masters
  313. board [2][5] = "Who's second to Sam Snead in PGA Tour wins?";//Jack Nicklaus
  314. board [2][6] = "What tournament did Arnold Palmer say he would play in as long as he could walk?";//The Masters
  315. board [2][7] = "Who won a record six PGA Player of the Year Awards-Jack Nicklaus, Arnold Palmer or Tom Watson?";//Tom Watson
  316. board [2][8] = "Who summed up a playoff loss to Jack Nicklaus at the 1991 U. S. Senior Open with 'the Bear crushed the Mouse'?";//Chi Chi Rodriguez
  317. board [2][9] = "What golfer bid a tearful farewell to fans after playing his last U.S. Open, in 1994?";//Arnold Palmer
  318. board [2][10] = "Who became the youngest and oldest player to win the Masters, in 1963 and 1986?";//Jack Nicklaus
  319. board [2][11] = "What golfer's worst finish at the British Open from 1966 to 1980 was sixth?";//Jack Nicklaus
  320. board [2][12] = "What's the only Grand Slam event Lee Trevino never won?";//The Masters
  321. board [2][13] = "Who was the first Swedish golfer to win the U.S. Womens's Open two straight times?";//Annika Sorenstam
  322. board [2][14] = "Who's the most successful Zimbabwean golfer of all time?";//Nick Price
  323.  
  324. boolean used [][]=new boolean [3][15];
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335. //intro
  336. c.setBackgroundColor (new Color (4,31,155));
  337. c.clear ();
  338.  
  339. //menu
  340. c.setFont (new Font ("Serif", Font.BOLD, 40));
  341. c.drawString("Here are the rules: ", 190, 480);
  342. c.drawString("Press any key to begin", 190, 560);
  343. c.drawImage(logo, 280, 105, 310, 310);
  344. c.getChar();
  345. c.clear();
  346.  
  347. //second page
  348. c.setFont (new Font ("Serif", Font.BOLD, 16));
  349. c.drawString("Choose a category, Press 0 for hockey, 1 for ball, 2 for golf", 60, 100);
  350. c.setColor(new Color (210,102,4));
  351. c.setFont (new Font ("Serif", Font.PLAIN, 21));
  352. c.drawImage(logo, 280, 105, 310, 310);
  353. cat = c.readInt();
  354. c.clear();
  355. // for(int h=0; h<q; h++) {
  356. // quest= (int) (Math.random()*15+1);
  357. //
  358. // if(used[cat][quest]==true)
  359. // {
  360. // q++;
  361. // }
  362. // c.readInt ();
  363. // }
  364.  
  365. //the game
  366.  
  367.  
  368.  
  369. while(stage<15){
  370. quest= (int) (Math.random()*board[cat].length);
  371.  
  372. while(used[cat][quest]==true)quest= (int) (Math.random()*board[cat].length);
  373. used[cat][quest] = true;
  374. c.setColor(new Color (4,31,155));
  375. c.fillRect(0,0,1000,1000);
  376.  
  377. c.setColor(Color.white);
  378. c.setFont (new Font ("Serif", Font.PLAIN, 18));
  379. c.drawString(board[cat][quest],20,200);
  380. String choices[] = randomizeChoices(cat, quest);
  381. System.out.println(tempN[0]+1);
  382. c.setColor(Color.yellow);
  383. /*c.drawString(choices[0],50,400);
  384. c.drawString(choices[1],50,440);
  385. c.drawString(choices[2],50,480);
  386. c.drawString(choices[3],50,520);*/
  387. c.setCursor(20,0);
  388. c.println("1."+choices[0]);
  389. c.println("2."+choices[1]);
  390. c.println("3."+choices[2]);
  391. c.println("4."+choices[3]);
  392. c.println("\n");
  393. lvl();
  394. int choice = c.readInt();
  395. if (choice == tempN[0]+1){
  396. if(stage==14){
  397. c.println("\n");
  398. c.println("You won!");
  399. c.getChar();
  400. System.exit(0);} else{
  401. c.println("\n");
  402. c.println("Correct!");
  403. c.getChar();
  404. stage++;}
  405. }
  406. else {
  407. c.println("\n");
  408. c.println("Inorrect!");
  409. c.getChar();
  410. System.exit(0);
  411. }}
  412. /*if ()
  413. for (int i =0; i<15; i++) {
  414. c.drawString (""+i+1, 200, 100);
  415. }*/
  416.  
  417. }
  418.  
  419. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement