Advertisement
Buffdude1100

Updated Pizza Randomizer2

Jul 1st, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.55 KB | None | 0 0
  1. import java.util.*;
  2. import javax.swing.*;
  3. public class Main
  4. {
  5.     private static void createAndShowGUI() {
  6.         JFrame frame = new JFrame("Pizza Randomizer 2000");    
  7.  
  8.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  9.         ArrayList<String> totalPizza = new ArrayList<>();
  10.         Toppings func = new Toppings();
  11.         func.Dough();
  12.         func.Base();
  13.         func.Sauce();
  14.         func.Cheese();
  15.         func.Vegetables();
  16.         func.Meats();
  17.         func.AfterBakes();
  18.         totalPizza=func.GiveArray();
  19.         String str="";
  20.         for (int i=0; i<totalPizza.size(); i++)
  21.         {
  22.             str += totalPizza.get(i) + "\n";
  23.         }
  24.         JLabel Label = new JLabel(str);
  25.         frame.getContentPane().add(Label);
  26.         frame.setSize(500, 500);
  27.         //frame.pack();
  28.         frame.setVisible(true);
  29.     }
  30.         public static void main(String[] args)
  31.         {
  32.         createAndShowGUI();
  33.         }
  34.        
  35. }
  36.  
  37. import java.util.*;
  38. public class Toppings
  39. {
  40.     ArrayList<String> total = new ArrayList<>();
  41.     Random rand = new Random();
  42.         public void Dough()
  43.         {
  44.                 int DoughRandom=rand.nextInt(3);
  45.                 String[] Doughs = {"Gluten-Free", "Original", "Wheat"};
  46.                 total.add("Dough: ");
  47.                 total.add(Doughs[DoughRandom]);
  48.         }
  49.         public void Base()
  50.         {
  51.                 int BaseRandom=rand.nextInt(3);
  52.                 String[] Bases = {"\n\tHerb Butter", "\n\tOlive Oil", "\n\tButter"};
  53.                 total.add("\nBase: ");
  54.                 total.add(Bases[BaseRandom]);
  55.         }
  56.         public void Sauce()
  57.         {
  58.                 int SauceRandom1=rand.nextInt(5);
  59.                 String[] Sauces = {"\n\tAlfredo", "\n\tRed", "\n\tBBQ", "\n\tBuffalo", "\n\tPesto"};
  60.                 total.add("\nSauce: ");
  61.                 total.add(Sauces[SauceRandom1]);
  62.         }
  63.         public void Cheese()
  64.         {
  65.                 HashSet<String> Cheeses1 = new HashSet<String>();
  66.                 int CheeseRandom2=rand.nextInt(6);
  67.                 String[] Cheeses = {"\n\tMozzarella", "\n\tFeta", "\n\tParmesan", "\n\tGorgonzola", "\n\tRicotta", "\n\tDaiya"};
  68.                 total.add("\nCheeses: ");
  69.                 if (CheeseRandom2==0)
  70.                     total.add("\n\tNone");
  71.                 while (CheeseRandom2>0)
  72.                 {
  73.                         int CheeseRandom1=rand.nextInt(6);
  74.                         while (Cheeses1.contains(Cheeses[CheeseRandom1]))
  75.                                 CheeseRandom1=rand.nextInt(6);
  76.                         total.add(Cheeses[CheeseRandom1]);
  77.                         CheeseRandom2--;
  78.                         Cheeses1.add(Cheeses[CheeseRandom1]);
  79.                 }
  80.         }
  81.         public void Vegetables()
  82.         {
  83.         HashSet<String> Vegetables1 = new HashSet<String>();
  84.         int VegetablesRandom2 = rand.nextInt(16);
  85.         String[] Vegetables = {"\n\tBlack Olives", "\n\tMushrooms", "\n\tRed Onions", "\n\tGreen Peppers", "\n\tArtichokes", "\n\tTomatoes", "\n\tGarlic", "\n\tPineapple", "\n\tJalapeños", "\n\tCorn", "\n\tKalamata Olives", "\n\tCilantro", "\n\tBasil", "\n\tSpinach", "\n\tBanana Peppers", "\n\tRed Peppers"};
  86.         total.add("\nVegetables: ");
  87.         if (VegetablesRandom2==0)
  88.             total.add("\n\tNone");
  89.         while (VegetablesRandom2>0)
  90.         {
  91.                 int VegetablesRandom1=rand.nextInt(16);
  92.                 while (Vegetables1.contains(Vegetables[VegetablesRandom1]))
  93.                         VegetablesRandom1=rand.nextInt(16);
  94.                 total.add(Vegetables[VegetablesRandom1]);
  95.                 VegetablesRandom2--;
  96.                 Vegetables1.add(Vegetables[VegetablesRandom1]);
  97.         }
  98.         }
  99.         public void Meats()
  100.         {
  101.                 HashSet<String> Meats1 = new HashSet<String>();
  102.                 int MeatsRandom2 = rand.nextInt(7);
  103.                 String[] Meats = {"\n\tPepperoni", "\n\tSausage", "\n\tMeatball", "\n\tChicken", "\n\tSpicy Chicken", "\n\tHam", "\n\tBacon"};
  104.                 total.add("\nMeats: ");
  105.                 if (MeatsRandom2==0)
  106.                     total.add("\n\tNone");
  107.                 while(MeatsRandom2>0)
  108.                 {
  109.                         int MeatsRandom1=rand.nextInt(7);
  110.                         while (Meats1.contains(Meats[MeatsRandom1]))
  111.                                 MeatsRandom1=rand.nextInt(7);
  112.                         total.add(Meats[MeatsRandom1]);
  113.                         MeatsRandom2--;
  114.                         Meats1.add(Meats[MeatsRandom1]);
  115.                 }
  116.         }
  117.         public void AfterBakes()
  118.         {
  119.                 HashSet<String> AfterBakes1 = new HashSet<String>();
  120.                 int AfterBakesRandom2 = rand.nextInt(6);
  121.                 String[] AfterBakes = {"\n\tBBQ", "\n\tPesto", "\n\tRanch", "\n\tRed Sauce", "\n\tBasil", "\n\tBuffalo"};
  122.                 total.add("\nAfterbakes: ");
  123.                 if (AfterBakesRandom2==0)
  124.                     total.add("\n\tNone");
  125.                 while(AfterBakesRandom2>0)
  126.                 {
  127.                         int AfterBakesRandom1=rand.nextInt(6);
  128.                         while(AfterBakes1.contains(AfterBakes[AfterBakesRandom1]))
  129.                                 AfterBakesRandom1=rand.nextInt(6);
  130.                         total.add(AfterBakes[AfterBakesRandom1]);
  131.                         AfterBakesRandom2--;
  132.                         AfterBakes1.add(AfterBakes[AfterBakesRandom1]);
  133.                 }
  134.         }
  135.         public ArrayList<String> GiveArray()
  136.         {
  137.             return total;
  138.         }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement