Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pizza.pasta;
- import java.io.IOException;
- import static java.lang.Integer.parseInt;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Scanner;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.JOptionPane;
- import javax.swing.SwingUtilities;
- public class PizzaPasta {
- public static HashMap<Integer, Integer> moneyStash = new HashMap<>();
- public static HashMap<Integer, String> nameStash = new HashMap<>();
- public static int introPanel=3;
- static int debug=0;
- static int IDs=0;
- public static boolean isInteger(String string) {
- //a method that checks if the given input is an integer or not
- //returns true if it is, and false if it isn't
- //used for waterproofing input screens incase user errors happen
- if(debug==1){
- System.out.println("isInteger method starting");
- }
- try {
- Integer.valueOf(string);
- return true;
- } catch (NumberFormatException e) {
- if(debug==1){
- System.out.println("isInteger method ending");
- }
- return false;
- }
- }
- //a method that checks if the given input is an integer or not
- //returns true if it is, and false if it isn't
- //used for waterproofing input screens incase user errors happen
- public static boolean isNull(String string){
- //a method that checks if a string contains a null
- //mostly for saving space
- boolean checker=false;
- if ("null".equals(string)){
- checker=true;
- }
- if (!"null".equals(string)){
- checker=false;
- }
- return checker;
- }
- //a method that checks if a string contains a null
- //mostly for saving space
- public static int debugger(int state){
- //a method turns on a few debug prints when used
- if(state==1 && debug==0){
- System.out.println("debug mode turned on");
- debug=1;
- }
- else if(state==0 && debug==1){
- System.out.println("debug mode turned off");
- debug=0;
- }
- else {
- System.out.println("error this message should not show");
- }
- return debug;
- }
- //a method turns on a few debug prints when used
- public static void arrayListPrinter(ArrayList<String> arrayList) {
- //a method that prints the given arrayList
- System.out.println("Printing arrayList: "+arrayList);
- for(int i=0; i<arrayList.size(); i++){
- System.out.println("#"+(i+1)+": "+arrayList.get(i)+" ");
- }
- }
- //a method that prints the given arrayList
- public static void listPrinter(List<String> list) {
- //a method that prints the given list
- System.out.println("Printing list: "+list);
- for(int i=0; i<list.size(); i++){
- System.out.println("#"+(i+1)+": "+list.get(i)+" ");
- }
- }
- //a method that prints the given list
- public static int RNG(int max, int min){
- //a method that creates a randomized value that has a set max and minimal value when called
- //used for maths and such
- int rng;
- if(debug==1){
- System.out.println("RNG method starting");
- }
- do{rng=(int)(Math.random()*max);
- }while (rng<=min);
- if (debug==1){
- System.out.println("RNG: "+rng);
- }
- if(debug==1){
- System.out.println("RNG method ending");
- }
- return rng;
- }
- //a method that creates a randomized value that has a set max and minimal value when called
- //used for maths and such
- public static String collector(List<String> list, int desiredVariable){
- //a method that fetches a given value from the given list when the method is called
- //also checks if the variable is in the bounds of the list, and returns an error message if it isn't
- String string="";
- if(debug==1){
- System.out.println("collector method starting");
- }
- int variable=(desiredVariable)-1;
- if ((variable-1)<list.size()){
- string= list.get(variable);
- } else if (variable>list.size()){
- System.out.println("error, number larger than the list");
- }
- if(debug==1){
- System.out.println("collector method ending, collector collected: "+string);
- }
- return string;
- }
- //a method that fetches a given value from the given list when the method is called
- //also checks if the variable is in the bounds of the list, and returns an error message if it isn't
- public static String nameGenerator(){
- //a method that creates a randomized name from the list
- //has a small chance of giving a middle name
- String constructName;
- if(debug==1){
- System.out.println("nameGenerator method starting");
- }
- 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");
- 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");
- 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");
- List<String> order = Arrays.asList("Pizza (with toppings of customers choice)","Kebab with fries","Kebab with rice","Kebab in a skewer","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","");
- List<String> orderDetails = Arrays.asList("","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","");
- constructName=collector(nameList,(RNG(nameList.size(),1)));
- if (debug==1){
- System.out.println("constructName #1: "+constructName);
- }
- if ((RNG(100,1))>80){
- constructName=constructName+" "+collector(middleNameList,(RNG(middleNameList.size(),1)));
- if (debug==1){
- System.out.println("constructName #2: "+constructName);
- }
- }
- constructName=constructName+" "+collector(surNameList,RNG(surNameList.size(),1));
- if (debug==1){
- System.out.println("constructName #3: "+constructName);
- }
- if(debug==1){
- System.out.println("nameGenerator method ending");
- }
- return constructName;
- }
- //a method that creates a randomized name from the list
- //has a small chance of giving a middle name
- public static String bake(int numberOfToppings, String pizza, int startingPrice){
- //a method that bakes a pizza, combining the ingredients while also calculating a price
- //because why not
- if(debug==1){
- System.out.println("bake method starting");
- }
- String conPizza="";
- if (numberOfToppings<=5){
- conPizza=String.valueOf(startingPrice+(1*numberOfToppings));
- }
- else if (numberOfToppings<=10 && numberOfToppings>5){
- conPizza=String.valueOf(startingPrice+(1.25*numberOfToppings));
- }
- else if (numberOfToppings<=15 && numberOfToppings>10){
- conPizza=String.valueOf(startingPrice+(1.5*numberOfToppings));
- }
- else if (numberOfToppings<=20 && numberOfToppings>15){
- conPizza=String.valueOf(startingPrice+(2*numberOfToppings));
- }
- else if (numberOfToppings>20){
- conPizza=String.valueOf(startingPrice+(3*numberOfToppings));
- }
- if (debug==1){
- System.out.println("pizza price: "+conPizza+"€");
- }
- pizza=(conPizza+"€, "+pizza);
- if(debug==1){
- System.out.println("bake method ending");
- }
- return pizza;
- }
- //a method that bakes a pizza, combining the ingredients while also calculating a price
- //because why not
- public static String pizzaConstructor(int numberOfToppings, int startingPrice){
- //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
- String constructPizza="", cookedPizza;
- int i=0;
- boolean cheeseYes=false;
- 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");
- 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");
- if(debug==1){
- System.out.println("pizzaConstructor method starting");
- System.out.println("number of toppings: "+numberOfToppings);
- }
- do{
- //for (i<numberOfToppings;i++){
- if(cheeseYes!=true){
- if(RNG(100,1)>20){
- constructPizza=collector(pizzaTypeOfCheese, (RNG(pizzaTypeOfCheese.size(),1)));
- i++;
- if (debug==1){
- System.out.println("first constructPizza: "+constructPizza);
- System.out.println("first i: "+i);
- }
- cheeseYes=true;
- if(i<numberOfToppings){
- if (RNG(100,1)>80){
- constructPizza=collector(pizzaTypeOfCheese, (RNG(pizzaTypeOfCheese.size(),1)))+", "+constructPizza;
- i++;
- if (debug==1){
- System.out.println("extra cheese pizzaConstruct: "+constructPizza);
- System.out.println("extra cheese i: "+i);
- }}
- }
- }
- }
- if (i<numberOfToppings){
- constructPizza=constructPizza+", "+collector(pizzaToppings, (RNG(pizzaToppings.size(),1)));
- i++;
- if (debug==1){
- System.out.println("second constructPizza: "+constructPizza);
- System.out.println("second i: "+i);
- }}
- }while (i<numberOfToppings);
- cookedPizza=bake(numberOfToppings,constructPizza,startingPrice);
- if (debug==1){
- System.out.println("cooked pizza: "+cookedPizza);
- }
- if(debug==1){
- System.out.println("pizzaConstructor method ending");
- }
- //}
- return cookedPizza;
- }
- //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
- public static int walletPlus(int id,int plusAmount){
- //a method that adds money to a wallet
- int newTotal, oldTotal;
- if(debug==1){
- System.out.println("walletPlus method starting");
- }
- oldTotal=parseInt(bankReader(id));
- newTotal=plusAmount+oldTotal;
- moneyStasher(id,newTotal);
- if(debug==1){
- System.out.println("walletPlus method ending");
- }
- return newTotal;
- }
- //a method that adds money to a wallet
- public static int walletMinus(int id,int minusAmount){
- //a method that removes money from a wallet
- int newTotal, oldTotal;
- if(debug==1){
- System.out.println("walletMinus method starting");
- }
- oldTotal=parseInt(bankReader(id));
- newTotal=oldTotal-minusAmount;
- moneyStasher(id,newTotal);
- if(debug==1){
- System.out.println("walletMinus method ending");
- }
- return newTotal;
- }
- //a method that removes money from a wallet
- public static boolean walletChecker(int id,int money){
- //a method that detects if wallet has enough money to make the purchase
- boolean poorOrNot=false;
- int oldTotal,newTotal;
- if(debug==1){
- System.out.println("walletGenerator method starting");
- }
- oldTotal=parseInt(bankReader(id));
- newTotal=oldTotal-money;
- if (newTotal>=0){
- poorOrNot=true;
- }
- if (newTotal<0){
- poorOrNot=false;
- }
- if(debug==1){
- System.out.println("walletGenerator method ending");
- }
- return poorOrNot;
- }
- //a method that detects if wallet has enough money to make the purchase
- public static void moneyStasher(int id, int money){
- //a method used for saving the combination of bankdata and id data into a hashmap
- if(debug==1){
- System.out.println("bankStasher method starting");
- }
- moneyStash.put(id,money);
- if(debug==1){
- System.out.println("bankStasher method ending");
- }
- }
- //a method used for saving bankdata into a hashmap
- public static void nameStasher(int id, String name){
- //a method used for saving the combination of namedata and id data into a hashmap
- if(debug==1){
- System.out.println("nameStasher method starting");
- }
- nameStash.put(id,name);
- if(debug==1){
- System.out.println("nameStasher method ending");
- }
- }
- //a method used for saving namedata into a hashmap
- public static String nameReader(int position){
- //a method used for reading namedata via position id
- String result;
- if(debug==1){
- System.out.println("nameReader method starting");
- }
- result=nameStash.get(position);
- if(debug==1){
- System.out.println("nameReader method ending");
- }
- return result;
- }
- //a method used for reading namedata via position id
- public static String bankReader(int position){
- //a method used for reading bankdata via position id
- //String string="0";
- String string="";
- int strong=0;
- if(debug==1){
- System.out.println("bankReader method starting, position id:"+position);
- }
- System.out.println("bankReader debug before moneyStash.get(position): "+string);
- //string=String.valueOf(moneyStash.get(position));
- string =(""+(moneyStash.get(position)));
- System.out.println("bankReader debug after moneyStash.get(position): "+string);
- if(debug==1){
- System.out.println("bankReader method ending, this is the result: "+string);
- /*
- // populate hash map
- newmap.put(1, "tutorials");
- newmap.put(2, "point");
- newmap.put(3, "is best");
- // get value of key 3
- String val=(String)newmap.get(3);
- // check the value
- System.out.println("Value for key 3 is: " + val)
- */
- }
- return string;
- }
- //a method used for reading bankdata via position id
- public static void personGenerator(){
- //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
- int money=RNG(1000,0),id;
- if(debug==1){
- System.out.println("personGenerator method starting");
- }
- String name=nameGenerator();
- if(debug==1){
- System.out.println("nameGenerator result for personGenerator: "+name);
- }
- id=IDs; //IDs is the static value used to measure the people who have been generated thus far
- //starts at 0 and increases every time this method is called by one.
- nameStasher(id,name);
- moneyStasher(id,money);
- if(debug==1){
- System.out.println("ids for personGenerator person:"+name+":"+id);
- }
- IDs++;
- if(debug==1){
- System.out.println("personGenerator method ending");
- }
- }
- public static void main(String args[]){
- String one,ii,iii,iiii, combination, dumbo, tester, stringDump;
- double yks,kaks,kolme,nelj, ror;
- int stop=0, rando, reuseable, calc, savedNumber, startPane, numMax, numMin, listPanel,quitPanel=4,debugState, pane=0;
- Scanner in = new Scanner(System.in);
- boolean boolTest, exit=false;
- /*
- System.out.println("wallet has: "+Wallet.getMoneyAmount()+"€.");
- Wallet.setMoneyAmount(RNG(1000,1));
- System.out.println("wallet has: "+Wallet.getMoneyAmount()+"€.");
- */
- //debugger(1);
- if (debug==1){
- System.out.println("introPanel before run(): "+introPanel);
- }
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- try {
- introPanel=new JOptionPaneGUI().displayGUI();
- } catch (IOException ex) {
- Logger.getLogger(JOptionPaneGUI.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- });
- if (debug==1){
- System.out.println("introPanel after run(): "+introPanel);
- }
- //if (debug==1){
- do{
- //System.out.println("introPanel loop: "+introPanel);
- System.out.println("");
- } while(introPanel==3);
- //}
- if (debug==1){
- System.out.println("introPanel got out of loop: "+introPanel);
- }
- String[] quitButtons = { "No!", "Yes!"};
- String[] mainLoopButtons = { "Enter simulation chamber", "asd", "something else", "Cancel", "Debug tools","Cancel" };
- if(introPanel==0){
- do{
- startPane = JOptionPane.showOptionDialog(null, "What would you like to do?", "Main screen.",JOptionPane.WARNING_MESSAGE, 0, null, mainLoopButtons, mainLoopButtons[2]);
- System.out.println("starting joptionpane input debug: "+startPane);
- if(startPane==0){
- String[] simulationButtons = { "1 day.", "2 days.", "3 days.", "A full week.", "Users choice","Cancel" };
- JOptionPane.showMessageDialog(null,"Simulation chamber.");
- }
- if (startPane==1){
- JOptionPane.showMessageDialog(null, "personCreator-method tester");
- String[] simulationtestButtons = { "Continue","Cancel" };
- int rng,testPanel=3;
- System.out.println("asd");
- rng=RNG(20,1);
- do{
- System.out.println("asd loop");
- //testPanel=JOptionPane.showOptionDialog(null, "AA MY BRAINS NEED SLEEP.", "peopleGenerator()-test", JOptionPane.ERROR_MESSAGE, 0 , null, simulationtestButtons);
- 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]);
- //testPanel=JOptionPane.showOptionDialog(null, "AA MY BRAINS NEED SLEEP.", "peopleGenerator()-test", JOptionPane.ERROR_MESSAGE, 0 , null, simulationtestButtons);
- System.out.println("asd loop2");
- if (testPanel==0){
- System.out.println("creating people");
- //for (int i=0; i<rng; i++){
- personGenerator();
- personGenerator();
- personGenerator();
- //}
- System.out.println("done creating people");
- //}
- System.out.println("done");
- System.out.println("next, reading the data that was just created: ");
- //for(int i=0;i<rng;i++){
- System.out.println("nameReader at pos1: "+nameReader(1));
- System.out.println("bankReader at pos1: "+bankReader(1));
- //}
- }
- if(testPanel==1){
- JOptionPane.showMessageDialog(null,"Exiting menu.");
- }
- if(testPanel==-1){
- JOptionPane.showMessageDialog(null,"Exiting menu.");
- }
- }while(testPanel!=1 && testPanel!=-1);
- }
- if (startPane==2){
- JOptionPane.showMessageDialog(null, "hello");
- }
- if (startPane==5){
- JOptionPane.showMessageDialog(null, "canceling");
- if(debug==1){
- System.out.println("canceling from startmenu.");
- }
- }
- if (startPane==-1){
- JOptionPane.showMessageDialog(null, "canceling");
- }
- if (startPane==4){
- JOptionPane.showMessageDialog(null, "Debug tools menu");
- String [] debugTools = {"On", "Off", "Cancel"};
- String [] debugTools2 = {"On", "Off", "Cancel","Extra debug tools"};
- String [] extraDebugTools = {"pizzaTopping method", "nameGenerator method", "RNG method","isInteger method","stasher and reader methods","Cancel"};
- int debugPanel=7, extraDebugPanel=7;
- do{
- int i=0;
- if (debug==0){
- 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]);
- //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.
- }
- if (debug==1){
- 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]);
- //if debug==1 the button layout changes to show the extra debug options-button, which allows access to testing various methods directly
- }
- if(debug==1){
- System.out.println("debugPanel debug: "+debugPanel);
- }
- if (debugPanel==0 && debug==0 && i==0){
- debugger(1);
- JOptionPane.showMessageDialog(null,"Debugger turned on.");
- i=1;
- }
- if (debugPanel==0 && debug==1 && i==0){
- JOptionPane.showMessageDialog(null,"Debugger has already been turned on!");
- i=1;
- }
- if (debugPanel==1 && debug==1 && i==0){
- debugger(0);
- JOptionPane.showMessageDialog(null,"Debugger turned off.");
- i=1;
- }
- if (debugPanel==1 && debug==0 && i==0){
- JOptionPane.showMessageDialog(null,"Debugger has already been turned off!");
- i=1;
- }
- if (debugPanel==2 && debug==0){
- JOptionPane.showMessageDialog(null,"Exiting menu.");
- }
- if (debugPanel==-1 && debug==0){
- JOptionPane.showMessageDialog(null,"Exiting menu.");
- }
- if (debugPanel==3 && debug==1){
- JOptionPane.showMessageDialog(null,"Entering the extra debug screen.");
- do{
- 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]);
- if (debug==1){
- System.out.println("extraDebugPanel debug:"+extraDebugPanel);
- }
- if (extraDebugPanel==0){
- //pizzaTopping method tester
- JOptionPane.showMessageDialog(null, "pizzaTopping-method tester.");
- do{
- int toppings=parseInt(JOptionPane.showInputDialog(null,"How many toppings do you want?"));
- int startingPrice=parseInt(JOptionPane.showInputDialog(null,"Starting price of the pizza?"));
- System.out.println(pizzaConstructor(toppings,startingPrice));
- }while (pane!=-1 && pane!=2);
- }
- if (extraDebugPanel==1){
- //nameGenerator method
- JOptionPane.showMessageDialog(null, "nameGenerator-method tester.");
- do{
- String [] nameGeneratorButtons = {"Another","Cancel"};
- String name = ("Your new name is: "+nameGenerator()+"!");
- reuseable= JOptionPane.showOptionDialog(null, name, "title", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, nameGeneratorButtons, null);
- }while (reuseable!=1 && reuseable!=-1);
- }
- if (extraDebugPanel==2){
- //RNG method
- JOptionPane.showMessageDialog(null, "RNG-method tester.");
- do{
- numMax=parseInt(JOptionPane.showInputDialog(null, "Give the maximum number that can be created: "));
- numMin=parseInt(JOptionPane.showInputDialog(null, "Give minimum number: "));
- JOptionPane.showMessageDialog(null, "Your random number is: "+RNG(numMax,numMin)+"!");
- String [] RNGButtons = {"Continue","Cancel"};
- reuseable= JOptionPane.showOptionDialog(null, "Continue to roll numbers?", "RNG-method", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, RNGButtons, null);
- }while (reuseable!=1 && reuseable != -1);
- }
- if (extraDebugPanel==3){
- //isInteger method
- JOptionPane.showMessageDialog(null, "isInteger-method tester.");
- int again=3;
- do{
- String isInt=(JOptionPane.showInputDialog(null, "Input whatever you want, the method will check if it is a number or not: "));
- boolean bol=isInteger(isInt);
- JOptionPane.showMessageDialog(null, bol);
- String [] isIntegerButtons = {"Continue","Cancel"};
- if (bol==false){
- 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);
- }
- if (bol==true){
- 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);
- }
- }while (again!=1 && again != -1);
- }
- //String [] extraDebugTools = {"pizzaTopping method", "nameGenerator method", "RNG method","isInteger method","stasher and reader methods","Cancel"};
- if (extraDebugPanel==4){
- JOptionPane.showMessageDialog(null, "stasher and reader methods");
- //tests the stasher and reader methods. stashers save data into hashmaps, and readers read data from those hashmaps
- String [] stasherReaderButtons = {"moneyStasher","bankReader","moneyStasher and bankReader","nameStasher","nameReader","nameStasher and nameReader", "Cancel"};
- int stash;
- String nullTesterID,nullTesterMoney;
- do{
- 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);
- if (stash==0){
- JOptionPane.showMessageDialog(null, "moneyStasher. input a value you want as the id and a value you want to store as the money.");
- nullTesterID=JOptionPane.showInputDialog(null,"ID value:");
- if(isNull(nullTesterID)==false){
- if(isInteger(nullTesterID)==true){
- JOptionPane.showMessageDialog(null, "You input value "+nullTesterID+" for the ID.");
- nullTesterMoney=JOptionPane.showInputDialog(null,"money value:");
- if(isNull(nullTesterMoney)==false){
- if(isInteger(nullTesterMoney)==true){
- JOptionPane.showMessageDialog(null, "You input value "+nullTesterMoney+" for money.");
- moneyStasher(parseInt(nullTesterID),parseInt(nullTesterMoney));
- } else if(isInteger(nullTesterMoney)==false){
- JOptionPane.showMessageDialog(null, "Hey, that wasn't a number! Try again");
- }
- } else if(isNull(nullTesterMoney)==true){
- JOptionPane.showMessageDialog(null, "Hey, that was a null input! Try again");
- }
- } else if(isInteger(nullTesterID)==false){
- JOptionPane.showMessageDialog(null, "Hey, that wasn't a number! Try again");
- }
- } else if(isNull(nullTesterID)==true){
- JOptionPane.showMessageDialog(null, "Hey, that was a null input! Try again");
- }
- }
- if (stash==1){
- String bankReader, bankReaderResult;
- boolean isIntTester, nullTester;
- 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!");
- bankReader=JOptionPane.showInputDialog(null,"Which position do you wish to read? Give a number:");
- if(isInteger(bankReader)==false){
- JOptionPane.showMessageDialog(null,"That was not a number, try again.");
- } else if(isInteger(bankReader)==true){
- bankReaderResult=bankReader(parseInt(bankReader));
- System.out.println("bankReader found the following data: "+bankReaderResult);
- if(isNull(bankReaderResult)==true){
- JOptionPane.showMessageDialog(null, "There was no data at this location");
- String strong = bankReader(1);
- System.out.println("bankReader found the following data from the forced value: "+strong);
- } else if(isNull(bankReaderResult)==false){
- JOptionPane.showMessageDialog(null,"bankReader found the following data: "+bankReaderResult);
- //YOU STOPPED HERE
- //CURRENT PROBLEMS:
- //1) BANKREADER RETURNS NULLS ONLY
- //2) DEBUGTOOLS2 CANNOT BE EXITED
- //HAVE FUN ON YOUR BREAK
- }
- }
- }
- if (stash==2){
- JOptionPane.showMessageDialog(null, "moneyStasher and bankReader. Does the two methods moneyStasher and bankReader one after the other using the same ID value.");
- String bankReader, bankReaderResult;
- boolean isIntTester, nullTester;
- nullTesterID=JOptionPane.showInputDialog(null,"ID value:");
- if(isNull(nullTesterID)==false){
- if(isInteger(nullTesterID)==true){
- JOptionPane.showMessageDialog(null, "You input value "+nullTesterID+" for the ID.");
- nullTesterMoney=JOptionPane.showInputDialog(null,"money value:");
- if(isNull(nullTesterMoney)==false){
- if(isInteger(nullTesterMoney)==true){
- JOptionPane.showMessageDialog(null, "You input value "+nullTesterMoney+" for money.");
- moneyStasher(parseInt(nullTesterID),parseInt(nullTesterMoney));
- } else if(isInteger(nullTesterMoney)==false){
- JOptionPane.showMessageDialog(null, "Hey, that wasn't a number! Try again");
- }
- } else if(isNull(nullTesterMoney)==true){
- JOptionPane.showMessageDialog(null, "Hey, that was a null input! Try again");
- }
- } else if(isInteger(nullTesterID)==false){
- JOptionPane.showMessageDialog(null, "Hey, that wasn't a number! Try again");
- }
- } else if(isNull(nullTesterID)==true){
- JOptionPane.showMessageDialog(null, "Hey, that was a null input! Try again");
- }
- bankReaderResult=bankReader(parseInt(nullTesterID));
- if(isNull(bankReaderResult)==true){
- JOptionPane.showMessageDialog(null, "There was no data at this location");
- } else if(isNull(bankReaderResult)==false){
- JOptionPane.showMessageDialog(null,"bankReader found the following data: "+bankReaderResult);
- //YOU STOPPED HERE
- //CURRENT PROBLEMS:
- //1) BANKREADER RETURNS NULLS ONLY
- //2) DEBUGTOOLS2 CANNOT BE EXITED
- //HAVE FUN ON YOUR BREAK
- }
- }
- if (stash==3){
- JOptionPane.showMessageDialog(null, "nameStasher");
- }
- if (stash==4){
- JOptionPane.showMessageDialog(null, "nameReader");
- }
- if (stash==5){
- JOptionPane.showMessageDialog(null, "nameStasher and nameReader");
- }
- //stash= JOptionPane.showOptionDialog(null, "text", "title", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, stasherReaderButtons, null);
- //stash= JOptionPane.showOptionDialog(null, "text", "title", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, stasherReaderButtons, null);
- }while (stash!=6 && stash != -1);
- }
- if (extraDebugPanel==-1){
- JOptionPane.showMessageDialog(null, "Exiting menu.");
- //cancel method
- }
- if (extraDebugPanel==5){
- JOptionPane.showMessageDialog(null, "Exiting menu.");
- //cancel method
- }
- }while(extraDebugPanel!=-1 && extraDebugPanel!=5);
- } else if (debugPanel==3 && debug==1){
- JOptionPane.showMessageDialog(null,"Exiting menu.");
- }
- }while (debugPanel!=-1 && debugPanel!=4 /*&& ((debugPanel !=2) &&(debug==0))*/);
- }
- /*
- MUISTA SIIVOTA^^^^^^^^^
- else if (debugPanel==2 && debug==0){
- JOptionPane.showMessageDialog(null,"Exiting menu.");
- }
- */
- if (startPane==0){
- }
- } while (startPane!=-1 && startPane!=5);
- JOptionPane.showMessageDialog(null, "We hope to see you again soon!", "Goodbye!", JOptionPane.ERROR_MESSAGE);
- if (debug == 1){
- System.out.println("you have reached the end of the code! the loop ends here");
- System.out.println("this is a debug message");
- }
- System.out.println("Goodbye!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement