Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.42 KB | None | 0 0
  1. package pizza.pasta;
  2.  
  3. import java.io.IOException;
  4. import static java.lang.Integer.parseInt;
  5. import java.util.ArrayList;
  6. import java.util.Arrays;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Scanner;
  10. import java.util.logging.Level;
  11. import java.util.logging.Logger;
  12. import javax.swing.JOptionPane;
  13. import javax.swing.SwingUtilities;
  14.  
  15. public class PizzaPasta {
  16. public static HashMap<Integer, Integer> moneyStash = new HashMap<>();
  17. public static HashMap<Integer, String> nameStash = new HashMap<>();
  18. public static int introPanel=3;
  19. static int debug=0;
  20. static int IDs=0;
  21.  
  22.  
  23. public static boolean isInteger(String string) {
  24. //a method that checks if the given input is an integer or not
  25. //returns true if it is, and false if it isn't
  26. //used for waterproofing input screens incase user errors happen
  27. if(debug==1){
  28. System.out.println("isInteger method starting");
  29. }
  30. try {
  31. Integer.valueOf(string);
  32. return true;
  33. } catch (NumberFormatException e) {
  34. if(debug==1){
  35. System.out.println("isInteger method ending");
  36. }
  37. return false;
  38. }
  39. }
  40. //a method that checks if the given input is an integer or not
  41. //returns true if it is, and false if it isn't
  42. //used for waterproofing input screens incase user errors happen
  43.  
  44. public static boolean isNull(String string){
  45. //a method that checks if a string contains a null
  46. //mostly for saving space
  47. boolean checker=false;
  48.  
  49. if ("null".equals(string)){
  50. checker=true;
  51. }
  52. if (!"null".equals(string)){
  53. checker=false;
  54. }
  55.  
  56. return checker;
  57. }
  58. //a method that checks if a string contains a null
  59. //mostly for saving space
  60.  
  61. public static int debugger(int state){
  62. //a method turns on a few debug prints when used
  63. if(state==1 && debug==0){
  64. System.out.println("debug mode turned on");
  65. debug=1;
  66. }
  67. else if(state==0 && debug==1){
  68. System.out.println("debug mode turned off");
  69. debug=0;
  70. }
  71. else {
  72. System.out.println("error this message should not show");
  73. }
  74. return debug;
  75. }
  76. //a method turns on a few debug prints when used
  77.  
  78. public static void arrayListPrinter(ArrayList<String> arrayList) {
  79. //a method that prints the given arrayList
  80. System.out.println("Printing arrayList: "+arrayList);
  81. for(int i=0; i<arrayList.size(); i++){
  82. System.out.println("#"+(i+1)+": "+arrayList.get(i)+" ");
  83. }
  84. }
  85. //a method that prints the given arrayList
  86.  
  87. public static void listPrinter(List<String> list) {
  88. //a method that prints the given list
  89. System.out.println("Printing list: "+list);
  90. for(int i=0; i<list.size(); i++){
  91. System.out.println("#"+(i+1)+": "+list.get(i)+" ");
  92. }
  93.  
  94. }
  95. //a method that prints the given list
  96.  
  97. public static int RNG(int max, int min){
  98. //a method that creates a randomized value that has a set max and minimal value when called
  99. //used for maths and such
  100. int rng;
  101. if(debug==1){
  102. System.out.println("RNG method starting");
  103. }
  104. do{rng=(int)(Math.random()*max);
  105. }while (rng<=min);
  106. if (debug==1){
  107. System.out.println("RNG: "+rng);
  108. }
  109. if(debug==1){
  110. System.out.println("RNG method ending");
  111. }
  112. return rng;
  113. }
  114. //a method that creates a randomized value that has a set max and minimal value when called
  115. //used for maths and such
  116.  
  117. public static String collector(List<String> list, int desiredVariable){
  118. //a method that fetches a given value from the given list when the method is called
  119. //also checks if the variable is in the bounds of the list, and returns an error message if it isn't
  120. String string="";
  121. if(debug==1){
  122. System.out.println("collector method starting");
  123. }
  124. int variable=(desiredVariable)-1;
  125. if ((variable-1)<list.size()){
  126. string= list.get(variable);
  127.  
  128.  
  129. } else if (variable>list.size()){
  130. System.out.println("error, number larger than the list");
  131.  
  132. }
  133. if(debug==1){
  134. System.out.println("collector method ending, collector collected: "+string);
  135. }
  136. return string;
  137. }
  138. //a method that fetches a given value from the given list when the method is called
  139. //also checks if the variable is in the bounds of the list, and returns an error message if it isn't
  140.  
  141. public static String nameGenerator(){
  142. //a method that creates a randomized name from the list
  143. //has a small chance of giving a middle name
  144. String constructName;
  145.  
  146. if(debug==1){
  147. System.out.println("nameGenerator method starting");
  148. }
  149.  
  150. List<String> nameList = Arrays.asList("Arttu","Ada","Alex","Alphonse","Barry","Bella","Caleb", "Callie","Richard","Daisy","Evangeline","Edgar", "Edward","Fabian","Fionna","Gage","Gabriel","Harley","Hanna","Igor","Isabella","Jack","Jane","Kai","Kevin","Kimberly","Luke","Lily","Mia","Michael","Nathan","Naomi","Olivia","Oscar","Patrick","Penellope","Rob","Ruby","Rick","Sofia","Sebastian","Santeri","Tolkki","Thomas","Tristana","Viktor","Vivian","William","Willow","Xavier","Emma","Liam","Sophia","Mason","Jacob","James","Michelle","Frank","Roger","Daniel","Lucas","Ness","Ninten","Frisk","Chara","Ted","Rhys");
  151. List<String> middleNameList = Arrays.asList("von","A.","B.","C.","D.","E.","F.","G.","H.","Louis","Jade","Rose","Hope","Alexander","John","William","Robert","Mathew","Paige","Kate","Jean","Mary","Jack");
  152. List<String> surNameList = Arrays.asList("Anderson","Lico","Sunbreeze","Adams","Benson","Baker","Bailey","Bell","Campbell","Cook","Elric","Davis","Evans","Edwards","Flores","Green","Garcia","Hall","Hill","Jackson","Johnson","Jones","King","Lee","Lewis","Martinez","Morrigan","Nelson","Parker","Perez","Phillips","Reed","Reyes","Roberts","Robinson","Sanchez","Scott","Smith","Taylor","Thompson","Turner","Torres","Walker","White","Williams","Wilson","Wright","Young","Cooper","Miller","Baker","Morgan","Rogers","Abott","Acosta","Ali","Armstrong","Baxter","Fischer","Frank");
  153. List<String> order = Arrays.asList("Pizza (with toppings of customers choice)","Kebab with fries","Kebab with rice","Kebab in a skewer","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","");
  154. List<String> orderDetails = Arrays.asList("","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","");
  155.  
  156. constructName=collector(nameList,(RNG(nameList.size(),1)));
  157.  
  158. if (debug==1){
  159. System.out.println("constructName #1: "+constructName);
  160. }
  161.  
  162. if ((RNG(100,1))>80){
  163. constructName=constructName+" "+collector(middleNameList,(RNG(middleNameList.size(),1)));
  164. if (debug==1){
  165. System.out.println("constructName #2: "+constructName);
  166. }
  167. }
  168. constructName=constructName+" "+collector(surNameList,RNG(surNameList.size(),1));
  169. if (debug==1){
  170. System.out.println("constructName #3: "+constructName);
  171. }
  172. if(debug==1){
  173. System.out.println("nameGenerator method ending");
  174. }
  175. return constructName;
  176. }
  177. //a method that creates a randomized name from the list
  178. //has a small chance of giving a middle name
  179.  
  180. public static String bake(int numberOfToppings, String pizza, int startingPrice){
  181. //a method that bakes a pizza, combining the ingredients while also calculating a price
  182. //because why not
  183. if(debug==1){
  184. System.out.println("bake method starting");
  185. }
  186.  
  187. String conPizza="";
  188. if (numberOfToppings<=5){
  189. conPizza=String.valueOf(startingPrice+(1*numberOfToppings));
  190. }
  191. else if (numberOfToppings<=10 && numberOfToppings>5){
  192. conPizza=String.valueOf(startingPrice+(1.25*numberOfToppings));
  193. }
  194. else if (numberOfToppings<=15 && numberOfToppings>10){
  195. conPizza=String.valueOf(startingPrice+(1.5*numberOfToppings));
  196. }
  197. else if (numberOfToppings<=20 && numberOfToppings>15){
  198. conPizza=String.valueOf(startingPrice+(2*numberOfToppings));
  199. }
  200. else if (numberOfToppings>20){
  201. conPizza=String.valueOf(startingPrice+(3*numberOfToppings));
  202.  
  203. }
  204. if (debug==1){
  205. System.out.println("pizza price: "+conPizza+"€");
  206. }
  207. pizza=(conPizza+"€, "+pizza);
  208.  
  209. if(debug==1){
  210. System.out.println("bake method ending");
  211. }
  212.  
  213. return pizza;
  214. }
  215. //a method that bakes a pizza, combining the ingredients while also calculating a price
  216. //because why not
  217.  
  218. public static String pizzaConstructor(int numberOfToppings, int startingPrice){
  219. //a method that creates a randomized pizza from the toppings. the values fed into the method determine the number of toppings and the starting price of the pizza
  220. String constructPizza="", cookedPizza;
  221. int i=0;
  222. boolean cheeseYes=false;
  223.  
  224. List<String> pizzaToppings = Arrays.asList("Extra tomato","Garlic","Onion","Kebab","Jalapeno","Ham","Pineapple","Salami","Minced meat","Bacon","Sausage","Pepperoni","Mushrooms","Chicken","Figs","Avocado","Cherry tomatoes","Anchovies","Oysters","Tuna","Peppers","Spinach","Fried eggplant","Red onions","Sauerkraut","Beef","Italian salami","Caramelized onions","Prawns");
  225. List<String> pizzaTypeOfCheese = Arrays.asList("Cheese","Parmesani","Mozzarella","Cheddar cheese","Blue cheese","Provolone","Gouda","Gruyere","Ricotta","Colby","Edam","Emmental","Sheep cheese","Sharp cheddar cheese","Brie","Taleggio","Manchego", "Parmigiano-Reggiano", "Grana Padano","Goat cheese","Gorgonzola");
  226. if(debug==1){
  227. System.out.println("pizzaConstructor method starting");
  228.  
  229. System.out.println("number of toppings: "+numberOfToppings);
  230. }
  231.  
  232. do{
  233. //for (i<numberOfToppings;i++){
  234. if(cheeseYes!=true){
  235. if(RNG(100,1)>20){
  236. constructPizza=collector(pizzaTypeOfCheese, (RNG(pizzaTypeOfCheese.size(),1)));
  237. i++;
  238.  
  239. if (debug==1){
  240. System.out.println("first constructPizza: "+constructPizza);
  241. System.out.println("first i: "+i);
  242. }
  243.  
  244. cheeseYes=true;
  245. if(i<numberOfToppings){
  246. if (RNG(100,1)>80){
  247. constructPizza=collector(pizzaTypeOfCheese, (RNG(pizzaTypeOfCheese.size(),1)))+", "+constructPizza;
  248. i++;
  249.  
  250. if (debug==1){
  251. System.out.println("extra cheese pizzaConstruct: "+constructPizza);
  252. System.out.println("extra cheese i: "+i);
  253. }}
  254. }
  255. }
  256. }
  257. if (i<numberOfToppings){
  258. constructPizza=constructPizza+", "+collector(pizzaToppings, (RNG(pizzaToppings.size(),1)));
  259. i++;
  260. if (debug==1){
  261. System.out.println("second constructPizza: "+constructPizza);
  262. System.out.println("second i: "+i);
  263. }}
  264. }while (i<numberOfToppings);
  265. cookedPizza=bake(numberOfToppings,constructPizza,startingPrice);
  266.  
  267. if (debug==1){
  268. System.out.println("cooked pizza: "+cookedPizza);
  269. }
  270. if(debug==1){
  271. System.out.println("pizzaConstructor method ending");
  272. }
  273. //}
  274. return cookedPizza;
  275. }
  276. //a method that creates a randomized pizza from the toppings. the values fed into the method determine the number of toppings and the starting price of the pizza
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283. public static int walletPlus(int id,int plusAmount){
  284. //a method that adds money to a wallet
  285. int newTotal, oldTotal;
  286.  
  287. if(debug==1){
  288. System.out.println("walletPlus method starting");
  289. }
  290.  
  291. oldTotal=parseInt(bankReader(id));
  292. newTotal=plusAmount+oldTotal;
  293. moneyStasher(id,newTotal);
  294.  
  295. if(debug==1){
  296. System.out.println("walletPlus method ending");
  297. }
  298.  
  299. return newTotal;
  300. }
  301. //a method that adds money to a wallet
  302. public static int walletMinus(int id,int minusAmount){
  303. //a method that removes money from a wallet
  304. int newTotal, oldTotal;
  305.  
  306. if(debug==1){
  307. System.out.println("walletMinus method starting");
  308. }
  309.  
  310. oldTotal=parseInt(bankReader(id));
  311. newTotal=oldTotal-minusAmount;
  312. moneyStasher(id,newTotal);
  313.  
  314. if(debug==1){
  315. System.out.println("walletMinus method ending");
  316. }
  317. return newTotal;
  318. }
  319. //a method that removes money from a wallet
  320. public static boolean walletChecker(int id,int money){
  321. //a method that detects if wallet has enough money to make the purchase
  322. boolean poorOrNot=false;
  323. int oldTotal,newTotal;
  324.  
  325. if(debug==1){
  326. System.out.println("walletGenerator method starting");
  327. }
  328.  
  329. oldTotal=parseInt(bankReader(id));
  330. newTotal=oldTotal-money;
  331. if (newTotal>=0){
  332. poorOrNot=true;
  333. }
  334. if (newTotal<0){
  335. poorOrNot=false;
  336. }
  337.  
  338. if(debug==1){
  339. System.out.println("walletGenerator method ending");
  340. }
  341.  
  342. return poorOrNot;
  343. }
  344. //a method that detects if wallet has enough money to make the purchase
  345.  
  346. public static void moneyStasher(int id, int money){
  347. //a method used for saving the combination of bankdata and id data into a hashmap
  348. if(debug==1){
  349. System.out.println("bankStasher method starting");
  350. }
  351. moneyStash.put(id,money);
  352. if(debug==1){
  353. System.out.println("bankStasher method ending");
  354. }
  355.  
  356.  
  357. }
  358. //a method used for saving bankdata into a hashmap
  359. public static void nameStasher(int id, String name){
  360. //a method used for saving the combination of namedata and id data into a hashmap
  361. if(debug==1){
  362. System.out.println("nameStasher method starting");
  363. }
  364. nameStash.put(id,name);
  365.  
  366. if(debug==1){
  367. System.out.println("nameStasher method ending");
  368. }
  369. }
  370. //a method used for saving namedata into a hashmap
  371. public static String nameReader(int position){
  372. //a method used for reading namedata via position id
  373. String result;
  374. if(debug==1){
  375. System.out.println("nameReader method starting");
  376. }
  377. result=nameStash.get(position);
  378.  
  379. if(debug==1){
  380. System.out.println("nameReader method ending");
  381. }
  382.  
  383. return result;
  384. }
  385. //a method used for reading namedata via position id
  386. public static String bankReader(int position){
  387. //a method used for reading bankdata via position id
  388. //String string="0";
  389. String string="";
  390. int strong=0;
  391.  
  392. if(debug==1){
  393. System.out.println("bankReader method starting, position id:"+position);
  394. }
  395. System.out.println("bankReader debug before moneyStash.get(position): "+string);
  396. //string=String.valueOf(moneyStash.get(position));
  397. string =(""+(moneyStash.get(position)));
  398. System.out.println("bankReader debug after moneyStash.get(position): "+string);
  399. if(debug==1){
  400. System.out.println("bankReader method ending, this is the result: "+string);
  401.  
  402.  
  403. /*
  404. // populate hash map
  405. newmap.put(1, "tutorials");
  406. newmap.put(2, "point");
  407. newmap.put(3, "is best");
  408.  
  409. // get value of key 3
  410. String val=(String)newmap.get(3);
  411.  
  412. // check the value
  413. System.out.println("Value for key 3 is: " + val)
  414. */
  415. }
  416.  
  417. return string;
  418. }
  419. //a method used for reading bankdata via position id
  420.  
  421.  
  422. public static void personGenerator(){
  423. //a method that creates a person every time it is called. generates a random name and a random sum of cash into their wallet by using other methods
  424. int money=RNG(1000,0),id;
  425.  
  426. if(debug==1){
  427. System.out.println("personGenerator method starting");
  428. }
  429.  
  430. String name=nameGenerator();
  431. if(debug==1){
  432. System.out.println("nameGenerator result for personGenerator: "+name);
  433. }
  434. id=IDs; //IDs is the static value used to measure the people who have been generated thus far
  435. //starts at 0 and increases every time this method is called by one.
  436. nameStasher(id,name);
  437. moneyStasher(id,money);
  438.  
  439. if(debug==1){
  440. System.out.println("ids for personGenerator person:"+name+":"+id);
  441. }
  442.  
  443. IDs++;
  444. if(debug==1){
  445. System.out.println("personGenerator method ending");
  446. }
  447. }
  448.  
  449. public static void main(String args[]){
  450. String one,ii,iii,iiii, combination, dumbo, tester, stringDump;
  451. double yks,kaks,kolme,nelj, ror;
  452. int stop=0, rando, reuseable, calc, savedNumber, startPane, numMax, numMin, listPanel,quitPanel=4,debugState, pane=0;
  453. Scanner in = new Scanner(System.in);
  454. boolean boolTest, exit=false;
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461. /*
  462. System.out.println("wallet has: "+Wallet.getMoneyAmount()+"€.");
  463. Wallet.setMoneyAmount(RNG(1000,1));
  464. System.out.println("wallet has: "+Wallet.getMoneyAmount()+"€.");
  465. */
  466.  
  467. //debugger(1);
  468.  
  469.  
  470.  
  471.  
  472. if (debug==1){
  473. System.out.println("introPanel before run(): "+introPanel);
  474. }
  475. SwingUtilities.invokeLater(new Runnable() {
  476. @Override
  477. public void run() {
  478. try {
  479. introPanel=new JOptionPaneGUI().displayGUI();
  480. } catch (IOException ex) {
  481. Logger.getLogger(JOptionPaneGUI.class.getName()).log(Level.SEVERE, null, ex);
  482. }
  483.  
  484. }
  485. });
  486.  
  487. if (debug==1){
  488. System.out.println("introPanel after run(): "+introPanel);
  489. }
  490.  
  491. //if (debug==1){
  492. do{
  493. //System.out.println("introPanel loop: "+introPanel);
  494. System.out.println("");
  495. } while(introPanel==3);
  496. //}
  497.  
  498. if (debug==1){
  499. System.out.println("introPanel got out of loop: "+introPanel);
  500. }
  501.  
  502. String[] quitButtons = { "No!", "Yes!"};
  503. String[] mainLoopButtons = { "Enter simulation chamber", "asd", "something else", "Cancel", "Debug tools","Cancel" };
  504.  
  505. if(introPanel==0){
  506.  
  507.  
  508. do{
  509. startPane = JOptionPane.showOptionDialog(null, "What would you like to do?", "Main screen.",JOptionPane.WARNING_MESSAGE, 0, null, mainLoopButtons, mainLoopButtons[2]);
  510.  
  511.  
  512.  
  513. System.out.println("starting joptionpane input debug: "+startPane);
  514.  
  515. if(startPane==0){
  516. String[] simulationButtons = { "1 day.", "2 days.", "3 days.", "A full week.", "Users choice","Cancel" };
  517. JOptionPane.showMessageDialog(null,"Simulation chamber.");
  518.  
  519.  
  520. }
  521.  
  522.  
  523. if (startPane==1){
  524. JOptionPane.showMessageDialog(null, "personCreator-method tester");
  525. String[] simulationtestButtons = { "Continue","Cancel" };
  526. int rng,testPanel=3;
  527. System.out.println("asd");
  528. rng=RNG(20,1);
  529. do{
  530. System.out.println("asd loop");
  531. //testPanel=JOptionPane.showOptionDialog(null, "AA MY BRAINS NEED SLEEP.", "peopleGenerator()-test", JOptionPane.ERROR_MESSAGE, 0 , null, simulationtestButtons);
  532. testPanel = JOptionPane.showOptionDialog(null, "Welcome! This is the debug corner. Turning the debug option on will make the program print debug messages as it's running. Do you wish to turn it on/off?", "Debug tools", JOptionPane.ERROR_MESSAGE, 0 , null, simulationtestButtons, simulationtestButtons[2]);
  533.  
  534.  
  535. //testPanel=JOptionPane.showOptionDialog(null, "AA MY BRAINS NEED SLEEP.", "peopleGenerator()-test", JOptionPane.ERROR_MESSAGE, 0 , null, simulationtestButtons);
  536. System.out.println("asd loop2");
  537. if (testPanel==0){
  538. System.out.println("creating people");
  539.  
  540. //for (int i=0; i<rng; i++){
  541. personGenerator();
  542. personGenerator();
  543. personGenerator();
  544. //}
  545. System.out.println("done creating people");
  546.  
  547. //}
  548.  
  549. System.out.println("done");
  550. System.out.println("next, reading the data that was just created: ");
  551. //for(int i=0;i<rng;i++){
  552. System.out.println("nameReader at pos1: "+nameReader(1));
  553. System.out.println("bankReader at pos1: "+bankReader(1));
  554. //}
  555. }
  556. if(testPanel==1){
  557. JOptionPane.showMessageDialog(null,"Exiting menu.");
  558. }
  559. if(testPanel==-1){
  560. JOptionPane.showMessageDialog(null,"Exiting menu.");
  561. }
  562. }while(testPanel!=1 && testPanel!=-1);
  563. }
  564. if (startPane==2){
  565. JOptionPane.showMessageDialog(null, "hello");
  566. }
  567. if (startPane==5){
  568. JOptionPane.showMessageDialog(null, "canceling");
  569. if(debug==1){
  570. System.out.println("canceling from startmenu.");
  571. }
  572.  
  573. }
  574. if (startPane==-1){
  575. JOptionPane.showMessageDialog(null, "canceling");
  576.  
  577. }
  578. if (startPane==4){
  579. JOptionPane.showMessageDialog(null, "Debug tools menu");
  580. String [] debugTools = {"On", "Off", "Cancel"};
  581. String [] debugTools2 = {"On", "Off", "Cancel","Extra debug tools"};
  582. String [] extraDebugTools = {"pizzaTopping method", "nameGenerator method", "RNG method","isInteger method","stasher and reader methods","Cancel"};
  583.  
  584. int debugPanel=7, extraDebugPanel=7;
  585. do{
  586. int i=0;
  587. if (debug==0){
  588. debugPanel = JOptionPane.showOptionDialog(null, "Welcome! This is the debug corner. Turning the debug option on will make the program print debug messages as it's running. Do you wish to turn it on/off?", "Debug tools", JOptionPane.ERROR_MESSAGE, 0 , null, debugTools, debugTools[2]);
  589. //at this point the program checks for the current debug state. if debug==0, it means debug is not on, so the menu only shows three buttons.
  590. }
  591. if (debug==1){
  592. debugPanel = JOptionPane.showOptionDialog(null, "Welcome! This is the debug corner. Turning the debug option on will make the program print debug messages as it's running. Do you wish to turn it on/off?", "Debug tools", JOptionPane.ERROR_MESSAGE, 0 , null, debugTools2, debugTools2[2]);
  593. //if debug==1 the button layout changes to show the extra debug options-button, which allows access to testing various methods directly
  594. }
  595. if(debug==1){
  596. System.out.println("debugPanel debug: "+debugPanel);
  597. }
  598. if (debugPanel==0 && debug==0 && i==0){
  599. debugger(1);
  600. JOptionPane.showMessageDialog(null,"Debugger turned on.");
  601. i=1;
  602. }
  603. if (debugPanel==0 && debug==1 && i==0){
  604. JOptionPane.showMessageDialog(null,"Debugger has already been turned on!");
  605. i=1;
  606. }
  607. if (debugPanel==1 && debug==1 && i==0){
  608. debugger(0);
  609. JOptionPane.showMessageDialog(null,"Debugger turned off.");
  610. i=1;
  611. }
  612. if (debugPanel==1 && debug==0 && i==0){
  613. JOptionPane.showMessageDialog(null,"Debugger has already been turned off!");
  614. i=1;
  615. }
  616. if (debugPanel==2 && debug==0){
  617. JOptionPane.showMessageDialog(null,"Exiting menu.");
  618. }
  619. if (debugPanel==-1 && debug==0){
  620. JOptionPane.showMessageDialog(null,"Exiting menu.");
  621. }
  622. if (debugPanel==3 && debug==1){
  623. JOptionPane.showMessageDialog(null,"Entering the extra debug screen.");
  624. do{
  625. extraDebugPanel = JOptionPane.showOptionDialog(null, "Extra debug tools screen. Here you can test various methods by themselves and see how they function.", "Extra debug tools", JOptionPane.ERROR_MESSAGE, 0 , null, extraDebugTools, extraDebugTools[2]);
  626. if (debug==1){
  627. System.out.println("extraDebugPanel debug:"+extraDebugPanel);
  628. }
  629. if (extraDebugPanel==0){
  630. //pizzaTopping method tester
  631. JOptionPane.showMessageDialog(null, "pizzaTopping-method tester.");
  632. do{
  633. int toppings=parseInt(JOptionPane.showInputDialog(null,"How many toppings do you want?"));
  634. int startingPrice=parseInt(JOptionPane.showInputDialog(null,"Starting price of the pizza?"));
  635. System.out.println(pizzaConstructor(toppings,startingPrice));
  636. }while (pane!=-1 && pane!=2);
  637. }
  638.  
  639. if (extraDebugPanel==1){
  640. //nameGenerator method
  641. JOptionPane.showMessageDialog(null, "nameGenerator-method tester.");
  642. do{
  643. String [] nameGeneratorButtons = {"Another","Cancel"};
  644. String name = ("Your new name is: "+nameGenerator()+"!");
  645. reuseable= JOptionPane.showOptionDialog(null, name, "title", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, nameGeneratorButtons, null);
  646. }while (reuseable!=1 && reuseable!=-1);
  647.  
  648.  
  649. }
  650. if (extraDebugPanel==2){
  651. //RNG method
  652. JOptionPane.showMessageDialog(null, "RNG-method tester.");
  653. do{
  654. numMax=parseInt(JOptionPane.showInputDialog(null, "Give the maximum number that can be created: "));
  655. numMin=parseInt(JOptionPane.showInputDialog(null, "Give minimum number: "));
  656. JOptionPane.showMessageDialog(null, "Your random number is: "+RNG(numMax,numMin)+"!");
  657.  
  658. String [] RNGButtons = {"Continue","Cancel"};
  659. reuseable= JOptionPane.showOptionDialog(null, "Continue to roll numbers?", "RNG-method", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, RNGButtons, null);
  660. }while (reuseable!=1 && reuseable != -1);
  661. }
  662. if (extraDebugPanel==3){
  663. //isInteger method
  664. JOptionPane.showMessageDialog(null, "isInteger-method tester.");
  665. int again=3;
  666. do{
  667. String isInt=(JOptionPane.showInputDialog(null, "Input whatever you want, the method will check if it is a number or not: "));
  668. boolean bol=isInteger(isInt);
  669. JOptionPane.showMessageDialog(null, bol);
  670.  
  671. String [] isIntegerButtons = {"Continue","Cancel"};
  672. if (bol==false){
  673. again= JOptionPane.showOptionDialog(null, "Your input "+isInt+" returned a "+bol+", so it wasn't a number!", "Your input was a false!", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, isIntegerButtons, null);
  674. }
  675. if (bol==true){
  676. again= JOptionPane.showOptionDialog(null, "Your input "+isInt+" returned a "+bol+", so it was a number! Hooray!", "Your input was a true!", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, isIntegerButtons, null);
  677. }
  678. }while (again!=1 && again != -1);
  679. }
  680. //String [] extraDebugTools = {"pizzaTopping method", "nameGenerator method", "RNG method","isInteger method","stasher and reader methods","Cancel"};
  681.  
  682. if (extraDebugPanel==4){
  683. JOptionPane.showMessageDialog(null, "stasher and reader methods");
  684. //tests the stasher and reader methods. stashers save data into hashmaps, and readers read data from those hashmaps
  685. String [] stasherReaderButtons = {"moneyStasher","bankReader","moneyStasher and bankReader","nameStasher","nameReader","nameStasher and nameReader", "Cancel"};
  686. int stash;
  687. String nullTesterID,nullTesterMoney;
  688. do{
  689. stash= JOptionPane.showOptionDialog(null, "Which method would you like to test?", "stashers and readers.", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, stasherReaderButtons, null);
  690. if (stash==0){
  691. JOptionPane.showMessageDialog(null, "moneyStasher. input a value you want as the id and a value you want to store as the money.");
  692. nullTesterID=JOptionPane.showInputDialog(null,"ID value:");
  693. if(isNull(nullTesterID)==false){
  694. if(isInteger(nullTesterID)==true){
  695. JOptionPane.showMessageDialog(null, "You input value "+nullTesterID+" for the ID.");
  696. nullTesterMoney=JOptionPane.showInputDialog(null,"money value:");
  697. if(isNull(nullTesterMoney)==false){
  698. if(isInteger(nullTesterMoney)==true){
  699. JOptionPane.showMessageDialog(null, "You input value "+nullTesterMoney+" for money.");
  700. moneyStasher(parseInt(nullTesterID),parseInt(nullTesterMoney));
  701.  
  702. } else if(isInteger(nullTesterMoney)==false){
  703. JOptionPane.showMessageDialog(null, "Hey, that wasn't a number! Try again");
  704. }
  705. } else if(isNull(nullTesterMoney)==true){
  706. JOptionPane.showMessageDialog(null, "Hey, that was a null input! Try again");
  707.  
  708.  
  709.  
  710. }
  711.  
  712. } else if(isInteger(nullTesterID)==false){
  713. JOptionPane.showMessageDialog(null, "Hey, that wasn't a number! Try again");
  714. }
  715. } else if(isNull(nullTesterID)==true){
  716. JOptionPane.showMessageDialog(null, "Hey, that was a null input! Try again");
  717.  
  718.  
  719.  
  720. }
  721.  
  722. }
  723. if (stash==1){
  724. String bankReader, bankReaderResult;
  725. boolean isIntTester, nullTester;
  726.  
  727. JOptionPane.showMessageDialog(null, "bankReader. Reads data saved through moneyStasher. Note: if the simulation nor the method have been used yet there won't be any data to read!");
  728. bankReader=JOptionPane.showInputDialog(null,"Which position do you wish to read? Give a number:");
  729.  
  730. if(isInteger(bankReader)==false){
  731. JOptionPane.showMessageDialog(null,"That was not a number, try again.");
  732. } else if(isInteger(bankReader)==true){
  733. bankReaderResult=bankReader(parseInt(bankReader));
  734. System.out.println("bankReader found the following data: "+bankReaderResult);
  735. if(isNull(bankReaderResult)==true){
  736. JOptionPane.showMessageDialog(null, "There was no data at this location");
  737. String strong = bankReader(1);
  738. System.out.println("bankReader found the following data from the forced value: "+strong);
  739. } else if(isNull(bankReaderResult)==false){
  740. JOptionPane.showMessageDialog(null,"bankReader found the following data: "+bankReaderResult);
  741.  
  742. //YOU STOPPED HERE
  743. //CURRENT PROBLEMS:
  744. //1) BANKREADER RETURNS NULLS ONLY
  745. //2) DEBUGTOOLS2 CANNOT BE EXITED
  746. //HAVE FUN ON YOUR BREAK
  747. }
  748.  
  749.  
  750. }
  751.  
  752. }
  753. if (stash==2){
  754. JOptionPane.showMessageDialog(null, "moneyStasher and bankReader. Does the two methods moneyStasher and bankReader one after the other using the same ID value.");
  755.  
  756. String bankReader, bankReaderResult;
  757. boolean isIntTester, nullTester;
  758.  
  759. nullTesterID=JOptionPane.showInputDialog(null,"ID value:");
  760. if(isNull(nullTesterID)==false){
  761. if(isInteger(nullTesterID)==true){
  762. JOptionPane.showMessageDialog(null, "You input value "+nullTesterID+" for the ID.");
  763. nullTesterMoney=JOptionPane.showInputDialog(null,"money value:");
  764. if(isNull(nullTesterMoney)==false){
  765. if(isInteger(nullTesterMoney)==true){
  766. JOptionPane.showMessageDialog(null, "You input value "+nullTesterMoney+" for money.");
  767. moneyStasher(parseInt(nullTesterID),parseInt(nullTesterMoney));
  768.  
  769. } else if(isInteger(nullTesterMoney)==false){
  770. JOptionPane.showMessageDialog(null, "Hey, that wasn't a number! Try again");
  771. }
  772. } else if(isNull(nullTesterMoney)==true){
  773. JOptionPane.showMessageDialog(null, "Hey, that was a null input! Try again");
  774.  
  775.  
  776.  
  777. }
  778.  
  779. } else if(isInteger(nullTesterID)==false){
  780. JOptionPane.showMessageDialog(null, "Hey, that wasn't a number! Try again");
  781. }
  782. } else if(isNull(nullTesterID)==true){
  783. JOptionPane.showMessageDialog(null, "Hey, that was a null input! Try again");
  784.  
  785.  
  786.  
  787. }
  788.  
  789. bankReaderResult=bankReader(parseInt(nullTesterID));
  790. if(isNull(bankReaderResult)==true){
  791. JOptionPane.showMessageDialog(null, "There was no data at this location");
  792. } else if(isNull(bankReaderResult)==false){
  793. JOptionPane.showMessageDialog(null,"bankReader found the following data: "+bankReaderResult);
  794.  
  795.  
  796. //YOU STOPPED HERE
  797. //CURRENT PROBLEMS:
  798. //1) BANKREADER RETURNS NULLS ONLY
  799. //2) DEBUGTOOLS2 CANNOT BE EXITED
  800. //HAVE FUN ON YOUR BREAK
  801. }
  802.  
  803.  
  804. }
  805.  
  806. if (stash==3){
  807. JOptionPane.showMessageDialog(null, "nameStasher");
  808. }
  809. if (stash==4){
  810. JOptionPane.showMessageDialog(null, "nameReader");
  811. }
  812. if (stash==5){
  813. JOptionPane.showMessageDialog(null, "nameStasher and nameReader");
  814. }
  815.  
  816.  
  817.  
  818.  
  819. //stash= JOptionPane.showOptionDialog(null, "text", "title", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, stasherReaderButtons, null);
  820.  
  821. //stash= JOptionPane.showOptionDialog(null, "text", "title", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, stasherReaderButtons, null);
  822.  
  823. }while (stash!=6 && stash != -1);
  824.  
  825.  
  826. }
  827. if (extraDebugPanel==-1){
  828. JOptionPane.showMessageDialog(null, "Exiting menu.");
  829. //cancel method
  830. }
  831. if (extraDebugPanel==5){
  832. JOptionPane.showMessageDialog(null, "Exiting menu.");
  833. //cancel method
  834. }
  835. }while(extraDebugPanel!=-1 && extraDebugPanel!=5);
  836.  
  837. } else if (debugPanel==3 && debug==1){
  838. JOptionPane.showMessageDialog(null,"Exiting menu.");
  839. }
  840. }while (debugPanel!=-1 && debugPanel!=4 /*&& ((debugPanel !=2) &&(debug==0))*/);
  841. }
  842.  
  843.  
  844.  
  845. /*
  846.  
  847. MUISTA SIIVOTA^^^^^^^^^
  848.  
  849. else if (debugPanel==2 && debug==0){
  850. JOptionPane.showMessageDialog(null,"Exiting menu.");
  851. }
  852. */
  853.  
  854.  
  855.  
  856.  
  857. if (startPane==0){
  858.  
  859. }
  860.  
  861. } while (startPane!=-1 && startPane!=5);
  862.  
  863.  
  864.  
  865. JOptionPane.showMessageDialog(null, "We hope to see you again soon!", "Goodbye!", JOptionPane.ERROR_MESSAGE);
  866.  
  867. if (debug == 1){
  868. System.out.println("you have reached the end of the code! the loop ends here");
  869. System.out.println("this is a debug message");
  870. }
  871. System.out.println("Goodbye!");
  872. }
  873.  
  874. }
  875. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement