Advertisement
Guest User

Pokemon Battle!

a guest
Dec 4th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.55 KB | None | 0 0
  1. /*
  2. * APCS Project 1: FracCalc
  3. * Name: Kyle Phan
  4. * Period: 6
  5. * Checkpoint: 1, 2
  6. * Date: 10/24/16
  7. *
  8. */
  9. import java.util.Scanner;
  10. public class Pokemon
  11. {
  12. /* whole = the whole string
  13. * wholeDos = the second whole string
  14. * whole2 = the whole int
  15. * whole3 = the second whole int
  16. */
  17.  
  18. public static void main(String[] args)
  19. {
  20. Scanner encounter = new Scanner(System.in);
  21. System.out.println("A wild Spearow appeared!");
  22. System.out.println("Fight? (Y/N)");
  23. String fight = encounter.nextLine();
  24. if(fight.equals("N") || fight.equals("n"))
  25. {
  26. System.out.println("You got away safely.");
  27. }
  28. if(fight.equals("Y") || fight.equals("y"))
  29. {
  30. System.out.println(pokeBattle(fight));
  31. }
  32. }
  33.  
  34. public static String pokeBattle(String input)
  35. {
  36. Scanner battle = new Scanner(System.in);
  37. int EXP = 0;
  38. int squirtleHP = 12;
  39. int charmanderHP = 12;
  40. int bulbasaurHP = 12;
  41. int spearowHP = 11;
  42. int tackle = 4;
  43. int bubble = 6;
  44. int ember = 6;
  45. int vinewhip = 6;
  46. String movechosen;
  47. int move;
  48. System.out.println("What pokemon do you want to send out?");
  49. System.out.println("1 - Bulbasaur");
  50. System.out.println("2 - Charmander");
  51. System.out.println("3 - Squirtle");
  52. int pokes = battle.nextInt();
  53. String pokechosen;
  54. switch (pokes)
  55. {
  56. case 1: pokechosen = "Bulbasaur";
  57. break;
  58. case 2: pokechosen = "Charmander";
  59. break;
  60. case 3: pokechosen = "Squirtle";
  61. break;
  62. default: pokechosen = "Invalid month";
  63. break;
  64. }
  65. while(spearowHP > 0 && bulbasaurHP > 0 && charmanderHP > 0 && squirtleHP > 0)
  66. {
  67. if(pokechosen.equals("Bulbasaur"))
  68. {
  69. System.out.println("Spearow: " + spearowHP + " HP");
  70. System.out.println("Bulbasaur: " + bulbasaurHP + " HP");
  71. System.out.println("---------------------------------");
  72. System.out.println("What Bulbasaur will you use?");
  73. System.out.println("1 - Vine Whip");
  74. System.out.println("2 - Tackle");
  75. move = battle.nextInt();
  76. switch (move)
  77. {
  78. case 1: System.out.println("Bulbasaur used Vine Whip!");
  79. System.out.println("[ 6 DAMAGE ]");
  80. spearowHP = spearowHP - vinewhip;
  81. if(spearowHP > 0)
  82. {
  83. System.out.println("");
  84. System.out.println("Spearow used wing attack!");
  85. System.out.println("[ 4 DAMAGE ]");
  86. System.out.println("");
  87. bulbasaurHP = bulbasaurHP - tackle;
  88. }
  89. if(spearowHP < 0)
  90. {
  91. System.out.println("");
  92. System.out.println("Spearow Fainted");
  93. return "You gained 3 XP!";
  94. }
  95.  
  96. break;
  97. case 2: System.out.println("Bulbasaur used Tackle!");
  98. System.out.println("[ 4 DAMAGE ]");
  99. spearowHP = spearowHP - tackle;
  100. if(spearowHP > 0)
  101. {
  102. System.out.println("");
  103. System.out.println("Spearow used wing attack!");
  104. System.out.println("[ 4 DAMAGE ]");
  105. bulbasaurHP = bulbasaurHP - tackle;
  106. }
  107. if(spearowHP < 0)
  108. {
  109. System.out.println("");
  110. System.out.println("Spearow Fainted");
  111. return "You gained 3 XP!";
  112. }
  113.  
  114. break;
  115. default: movechosen = "Bulbasaur flailed!";
  116. if(spearowHP > 0)
  117. {
  118. System.out.println("Bulbasaur used flail!");
  119. System.out.println("Nothing happened...");
  120. System.out.println("");
  121. System.out.println("[ 0 DAMAGE ]");
  122. System.out.println("Spearow used wing attack!");
  123. System.out.println("[ 4 DAMAGE ]");
  124. System.out.println("");
  125. bulbasaurHP = bulbasaurHP - tackle;
  126. }
  127. if(spearowHP < 0)
  128. {
  129. System.out.println("");
  130. System.out.println("Spearow Fainted");
  131. return "You gained 3 XP!";
  132. }
  133.  
  134.  
  135. break;
  136. }
  137. }
  138. if(pokechosen.equals("Charmander"))
  139. {
  140. System.out.println("Spearow: " + spearowHP + " HP");
  141. System.out.println("Charmander: " + charmanderHP + " HP");
  142. System.out.println("---------------------------------");
  143. System.out.println("What move will Charmander use?");
  144. System.out.println("1 - Ember");
  145. System.out.println("2 - Tackle");
  146. move = battle.nextInt();
  147. switch (move)
  148. {
  149. case 1: System.out.println("Charmander used Ember!");
  150. System.out.println("[ 6 DAMAGE ]");
  151. spearowHP = spearowHP - ember;
  152. if(spearowHP > 0)
  153. {
  154. System.out.println("");
  155. System.out.println("Spearow used wing attack!");
  156. System.out.println("[ 4 DAMAGE ]");
  157. System.out.println("");
  158. charmanderHP = charmanderHP - tackle;
  159. }
  160. if(spearowHP < 0)
  161. {
  162. System.out.println("");
  163. System.out.println("Spearow Fainted");
  164. EXP++;
  165. return "You gained 3 XP!";
  166. }
  167.  
  168. break;
  169. case 2: System.out.println("Charmander used Tackle!");
  170. System.out.println("[ 4 DAMAGE ]");
  171. spearowHP = spearowHP - tackle;
  172. if(spearowHP > 0)
  173. {
  174. System.out.println("");
  175. System.out.println("Spearow used wing attack!");
  176. System.out.println("[ 4 DAMAGE ]");
  177. System.out.println("");
  178. charmanderHP = charmanderHP - tackle;
  179. }
  180. if(spearowHP < 0)
  181. {
  182. System.out.println("");
  183. System.out.println("Spearow Fainted");
  184. EXP++;
  185. return "You gained 3 XP!";
  186. }
  187.  
  188. break;
  189. default: movechosen = "Charmander flailed!";
  190. if(spearowHP > 0)
  191. {
  192. System.out.println("Charmander used flail!");
  193. System.out.println("Nothing happened...");
  194. System.out.println("[ 0 DAMAGE ]");
  195. System.out.println("");
  196. System.out.println("Spearow used wing attack!");
  197. System.out.println("[ 4 DAMAGE ]");
  198. System.out.println("");
  199. charmanderHP = charmanderHP - tackle;
  200. }
  201. if(spearowHP < 0)
  202. {
  203. System.out.println("");
  204. System.out.println("Spearow Fainted");
  205. EXP++;
  206. return "You gained 3 XP";
  207. }
  208.  
  209.  
  210. break;
  211. }
  212. }
  213. if(pokechosen.equals("Squirtle"))
  214. {
  215. System.out.println("Spearow: " + spearowHP + " HP");
  216. System.out.println("Squirtle: " + squirtleHP + " HP");
  217. System.out.println("---------------------------------");
  218. System.out.println("What move will Squirtle use?");
  219. System.out.println("1 - Bubble");
  220. System.out.println("2 - Tackle");
  221. move = battle.nextInt();
  222. switch (move)
  223. {
  224. case 1: System.out.println("Squirtle used Bubble!");
  225. System.out.println("[ 6 DAMAGE ]");
  226. spearowHP = spearowHP - bubble;
  227. if(spearowHP > 0)
  228. {
  229. System.out.println("");
  230. System.out.println("Spearow used wing attack!");
  231. System.out.println("[ 4 DAMAGE ]");
  232. System.out.println("");
  233. squirtleHP = squirtleHP - tackle;
  234. }
  235. if(spearowHP < 0)
  236. {
  237. System.out.println("");
  238. System.out.println("Spearow Fainted");
  239. return "You gained 3 XP!";
  240. }
  241.  
  242. break;
  243. case 2: System.out.println("Squirtle used Tackle!");
  244. System.out.println("[ 4 DAMAGE ]");
  245. spearowHP = spearowHP - tackle;
  246. if(spearowHP > 0)
  247. {
  248. System.out.println("");
  249. System.out.println("Spearow used wing attack!");
  250. System.out.println("[ 4 DAMAGE ]");
  251. System.out.println("");
  252. squirtleHP = squirtleHP - tackle;
  253. }
  254. if(spearowHP < 0)
  255. {
  256. System.out.println("");
  257. System.out.println("Spearow Fainted");
  258. return "You gained 3 XP!";
  259. }
  260.  
  261. break;
  262. default: movechosen = "Squirtle flailed!";
  263. if(spearowHP > 0)
  264. {
  265. System.out.println("Squirtle used flail!");
  266. System.out.println("Nothing happened...");
  267. System.out.println("[ 0 DAMAGE ]");
  268. System.out.println("");
  269. System.out.println("Spearow used wing attack!");
  270. System.out.println("[ 4 DAMAGE ]");
  271. System.out.println("");
  272. squirtleHP = squirtleHP - tackle;
  273. }
  274.  
  275. if(spearowHP < 0)
  276. {
  277. System.out.println("");
  278. System.out.println("Spearow Fainted");
  279. return "You gained 3 XP!";
  280. }
  281.  
  282.  
  283. break;
  284.  
  285. }
  286.  
  287. }
  288.  
  289. }
  290.  
  291. if(squirtleHP == 0 || charmanderHP == 0 || bulbasaurHP == 0)
  292. {
  293. return "You blacked out and went to the nearest Pokemon Center...";
  294. }
  295. else if(spearowHP <= 0 && charmanderHP < 12 && charmanderHP > 0)
  296. {
  297. System.out.println("Charmander is evolving...!");
  298. System.out.println("Charmander evolved into Charmeleon!");
  299. return "Charr.. Charr..";
  300. }
  301. else
  302. {
  303. return "";
  304. }
  305. }
  306. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement