Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3.  
  4. public class DigitsAndDragons {
  5.  
  6. public static Scanner sc = new Scanner(System.in);
  7.  
  8. public static Random random = new Random();
  9.  
  10. public static final int SINGLE = 9;
  11.  
  12. public static final int DOUBLE = 99;
  13.  
  14. public static void pressEnter() {
  15. System.out.println("Press ENTER to continue...");
  16. try {
  17. System.in.read();
  18. }
  19. catch(Exception e)
  20. {}
  21. }
  22.  
  23. public static int addProb(int diff) {
  24.  
  25. int num1 = random.nextInt(diff) + 1;
  26. int num2 = random.nextInt(diff) + 1;
  27.  
  28. int result = num1+num2;
  29.  
  30. System.out.print("What is "+num1+" + "+num2+"? ");
  31.  
  32. int ans = sc.nextInt();
  33. if(ans==result) {
  34. return 1;
  35. }
  36. else {
  37. return 0;
  38. }
  39.  
  40. }
  41.  
  42. public static int subProb(int diff) {
  43.  
  44. int num1 = random.nextInt(diff) + 1;
  45. int num2 = random.nextInt(diff) + 1;
  46. while (num2==num1) {
  47. num2 = random.nextInt(diff) + 1;
  48. }
  49. int max = Math.max(num1, num2);
  50. int min = Math.min(num1, num2);
  51. int result = max-min;
  52.  
  53. System.out.print("What is " +max+ " - " +min+ "? ");
  54.  
  55. int ans = sc.nextInt();
  56. if(ans==result) {
  57. return 1;
  58. }
  59. else {
  60. return 0;
  61. }
  62. }
  63.  
  64. public static void main(String[] args) {
  65.  
  66.  
  67.  
  68. System.out.println(" ___ _ _ _ __ ___ ");
  69. System.out.println(" | \\ (_) __ _ (_)| |_ ___ / _|___ | \\ _ _ __ _ __ _ ___ _ _ ___");
  70. System.out.println(" | |) || |/ _` || || _|(_-< > _|_ _| | |) || '_|/ _` |/ _` |/ _ \\| ' \\ (_-<");
  71. System.out.println(" |___/ |_|\\__, ||_| \\__|/__/ \\_____| |___/ |_| \\__,_|\\__, |\\___/|_||_|/__/");
  72. System.out.println(" |___/ |___/ ");
  73. System.out.println();
  74. System.out.print("Enter your name: ");
  75.  
  76. String name = sc.nextLine();
  77.  
  78. System.out.println();
  79.  
  80. System.out.print("In the Kingdom of Arithmetria you, "+name+", the Great Hero, is tasked with watching the Kingdom’s beloved \nprincess Algebrina.");
  81. System.out.print(" One day, the princess goes missing.");
  82. System.out.println(" A mysterious trail of smoke was seen leaving the \nKingdom, alongside a fallen princess crown.");
  83. System.out.println();
  84.  
  85. pressEnter();
  86.  
  87. System.out.println("The smoke trail dissipates in a clearance where you find two paths in front of you…");
  88. System.out.println();
  89. System.out.println("Enter 1 to go LEFT (Grades 1 & 2)");
  90. System.out.println("Enter 2 to go RIGHT (Grades 3 & 4)");
  91. System.out.println();
  92. System.out.print("What path will you take? ");
  93. int path = sc.nextInt();
  94. String trail = null;
  95. if(path==1) {
  96. trail = "LEFT";
  97. }
  98. else if(path==2) {
  99. trail = "RIGHT";
  100. }
  101.  
  102. int hp = 50;
  103. System.out.println();
  104. System.out.println("----------/ And So Your Jorney Begins /----------");
  105. System.out.println();
  106. System.out.println("Starting Health Points: "+hp);
  107. System.out.println();
  108. System.out.println("You, the Kingdom’s greatest hero follows the "+trail+" trail into the forest.");
  109. System.out.println("After several hours of hiking through the forest, you come across a figure standing in a small clearing..");
  110. System.out.println();
  111.  
  112. pressEnter();
  113.  
  114. System.out.println("The Wize Wizard of the forest tells you that a terrifying dragon has captured the princess. In order to \nsave Algebrina, you must solve the Great Problems of Arithmetic.");
  115. System.out.println();
  116. System.out.println(name+": Halt! Who are you?");
  117. System.out.println();
  118. System.out.println("Wize Wizard: Sir, I’m a mathemagician one of the last of my order, and if you wish to rescue princess \nAlgebrina you must first learn the ancient secret math skills.");
  119. System.out.println();
  120. System.out.print("Will you choose to learn the secret math skills with the help of the Wize Wizard? (yes or no): ");
  121. String tutorial = sc.next();
  122.  
  123. if (tutorial.equals("yes")) {
  124. //execute tutorial method
  125. }
  126. else if (tutorial.equals("no")) {
  127. System.out.println();
  128. System.out.println("You choose to ignore the Wizard, nothing good could come from and old man living in the woods, right?");
  129. System.out.println();
  130. }
  131.  
  132. pressEnter();
  133.  
  134. System.out.println("As you follow the charred path, a movement in the bushes startles your math senses. A large Rat comes out \nof the shadows.");
  135. System.out.println();
  136. System.out.println(" (\\,/)\r\n" +
  137. " oo '''//, _\r\n" +
  138. " ,/_;~, \\, / '\r\n" +
  139. " \"' \\ ( \\ !\r\n" +
  140. " ',| \\ |__.'\r\n" +
  141. " '~ '~----''");
  142. System.out.println();
  143. System.out.println("The Rat plunges to your shoulder and menacingly whispers to your ear:");
  144.  
  145. int level1 = addProb(SINGLE);
  146.  
  147. if (level1==1) {
  148. hp += 10;
  149. System.out.println();
  150. System.out.println("Correct! The Rat feels self conscious about your superior math skills and scuttles off");
  151. System.out.println("You gain a confidence boost! +10 health points!");
  152. System.out.println("Health Points: "+hp);
  153. }
  154. else {
  155. System.out.println();
  156. System.out.println("Oh no! While you’re thinking for your answer the Rat grabs all the cheese you packed for your trip and \nruns off. You shout back “Hey, Rat! Give it back! That’s NACHO Cheese!”. \nBut it was too late.");
  157. }
  158. System.out.println();
  159. pressEnter();
  160.  
  161. int level2 = subProb(SINGLE);
  162.  
  163. if (level2==1) {
  164. hp+=10;
  165. }
  166. else {
  167.  
  168. }
  169.  
  170. pressEnter();
  171.  
  172. int level3 = addProb(DOUBLE);
  173.  
  174. if (level3==1) {
  175. hp+=15;
  176. }
  177. else {
  178.  
  179. }
  180.  
  181. pressEnter();
  182.  
  183. int level4 = addProb(DOUBLE);
  184.  
  185. if (level4==1) {
  186. hp+=15;
  187. }
  188. else {
  189.  
  190. }
  191.  
  192. pressEnter();
  193.  
  194. int level5 = subProb(DOUBLE);
  195.  
  196. if (level5==1) {
  197. hp+=20;
  198. }
  199. else {
  200.  
  201. }
  202.  
  203. pressEnter();
  204.  
  205. System.out.println("Score: "+(level1+level2+level3+level4+level5));
  206.  
  207. }
  208.  
  209. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement