Advertisement
Buffdude1100

Updated Pizza Randomizer

Jul 1st, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.52 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.         System.out.println("Welcome to the pizza randomizer! I will choose a pizza with random toppings for you.");
  12.         func.Dough();
  13.         func.Base();
  14.         func.Sauce();
  15.         func.Cheese();
  16.         func.Vegetables();
  17.         func.Meats();
  18.         func.AfterBakes();
  19.         totalPizza=func.GiveArray();
  20.         JLabel Label = new JLabel(totalPizza);
  21.         frame.getContentPane().add(Label);
  22.         frame.pack();
  23.         frame.setVisible(true);
  24.     }
  25.         public static void main(String[] args)
  26.         {
  27.         createAndShowGUI();
  28.         }
  29.        
  30. }
  31.  
  32. import java.util.*;
  33. public class Toppings
  34. {
  35.     ArrayList<String> total = new ArrayList<>();
  36.         Random rand = new Random();
  37.         public void Dough()
  38.         {
  39.                 int DoughRandom=rand.nextInt(3);
  40.                 String[] Doughs = {"\n\tGluten-Free", "\n\tOriginal", "\n\tWheat"};
  41.                 total.add("\nDough: ");
  42.                 total.add(Doughs[DoughRandom]);
  43.         }
  44.         public void Base()
  45.         {
  46.                 int BaseRandom=rand.nextInt(3);
  47.                 String[] Bases = {"\n\tHerb Butter", "\n\tOlive Oil", "\n\tButter"};
  48.                 total.add("\nBase: ");
  49.                 total.add(Bases[BaseRandom]);
  50.         }
  51.         public void Sauce()
  52.         {
  53.                 int SauceRandom1=rand.nextInt(5);
  54.                 String[] Sauces = {"\n\tAlfredo", "\n\tRed", "\n\tBBQ", "\n\tBuffalo", "\n\tPesto"};
  55.                 total.add("\nSauce: ");
  56.                 total.add(Sauces[SauceRandom1]);
  57.         }
  58.         public void Cheese()
  59.         {
  60.                 HashSet<String> Cheeses1 = new HashSet<String>();
  61.                 int CheeseRandom2=rand.nextInt(6);
  62.                 String[] Cheeses = {"\n\tMozzarella", "\n\tFeta", "\n\tParmesan", "\n\tGorgonzola", "\n\tRicotta", "\n\tDaiya"};
  63.                 total.add("\nCheeses: ");
  64.                 if (CheeseRandom2==0)
  65.                     total.add("\n\tNone");
  66.                 while (CheeseRandom2>0)
  67.                 {
  68.                         int CheeseRandom1=rand.nextInt(6);
  69.                         while (Cheeses1.contains(Cheeses[CheeseRandom1]))
  70.                                 CheeseRandom1=rand.nextInt(6);
  71.                         total.add(Cheeses[CheeseRandom1]);
  72.                         CheeseRandom2--;
  73.                         Cheeses1.add(Cheeses[CheeseRandom1]);
  74.                 }
  75.         }
  76.         public void Vegetables()
  77.         {
  78.         HashSet<String> Vegetables1 = new HashSet<String>();
  79.         int VegetablesRandom2 = rand.nextInt(16);
  80.         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"};
  81.         total.add("\nVegetables: ");
  82.         if (VegetablesRandom2==0)
  83.             total.add("\n\tNone");
  84.         while (VegetablesRandom2>0)
  85.         {
  86.                 int VegetablesRandom1=rand.nextInt(16);
  87.                 while (Vegetables1.contains(Vegetables[VegetablesRandom1]))
  88.                         VegetablesRandom1=rand.nextInt(16);
  89.                 total.add(Vegetables[VegetablesRandom1]);
  90.                 VegetablesRandom2--;
  91.                 Vegetables1.add(Vegetables[VegetablesRandom1]);
  92.         }
  93.         }
  94.         public void Meats()
  95.         {
  96.                 HashSet<String> Meats1 = new HashSet<String>();
  97.                 int MeatsRandom2 = rand.nextInt(7);
  98.                 String[] Meats = {"\n\tPepperoni", "\n\tSausage", "\n\tMeatball", "\n\tChicken", "\n\tSpicy Chicken", "\n\tHam", "\n\tBacon"};
  99.                 total.add("\nMeats: ");
  100.                 if (MeatsRandom2==0)
  101.                     total.add("\n\tNone");
  102.                 while(MeatsRandom2>0)
  103.                 {
  104.                         int MeatsRandom1=rand.nextInt(7);
  105.                         while (Meats1.contains(Meats[MeatsRandom1]))
  106.                                 MeatsRandom1=rand.nextInt(7);
  107.                         total.add(Meats[MeatsRandom1]);
  108.                         MeatsRandom2--;
  109.                         Meats1.add(Meats[MeatsRandom1]);
  110.                 }
  111.         }
  112.         public void AfterBakes()
  113.         {
  114.                 HashSet<String> AfterBakes1 = new HashSet<String>();
  115.                 int AfterBakesRandom2 = rand.nextInt(6);
  116.                 String[] AfterBakes = {"\n\tBBQ", "\n\tPesto", "\n\tRanch", "\n\tRed Sauce", "\n\tBasil", "\n\tBuffalo"};
  117.                 total.add("\nAfterbakes: ");
  118.                 if (AfterBakesRandom2==0)
  119.                     total.add("\n\tNone");
  120.                 while(AfterBakesRandom2>0)
  121.                 {
  122.                         int AfterBakesRandom1=rand.nextInt(6);
  123.                         while(AfterBakes1.contains(AfterBakes[AfterBakesRandom1]))
  124.                                 AfterBakesRandom1=rand.nextInt(6);
  125.                         total.add(AfterBakes[AfterBakesRandom1]);
  126.                         AfterBakesRandom2--;
  127.                         AfterBakes1.add(AfterBakes[AfterBakesRandom1]);
  128.                 }
  129.         }
  130.         public ArrayList<String> GiveArray()
  131.         {
  132.             return total;
  133.         }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement