Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import javax.swing.*;
- public class Main
- {
- private static void createAndShowGUI() {
- JFrame frame = new JFrame("Pizza Randomizer 2000");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- ArrayList<String> totalPizza = new ArrayList<>();
- Toppings func = new Toppings();
- System.out.println("Welcome to the pizza randomizer! I will choose a pizza with random toppings for you.");
- func.Dough();
- func.Base();
- func.Sauce();
- func.Cheese();
- func.Vegetables();
- func.Meats();
- func.AfterBakes();
- totalPizza=func.GiveArray();
- JLabel Label = new JLabel(totalPizza);
- frame.getContentPane().add(Label);
- frame.pack();
- frame.setVisible(true);
- }
- public static void main(String[] args)
- {
- createAndShowGUI();
- }
- }
- import java.util.*;
- public class Toppings
- {
- ArrayList<String> total = new ArrayList<>();
- Random rand = new Random();
- public void Dough()
- {
- int DoughRandom=rand.nextInt(3);
- String[] Doughs = {"\n\tGluten-Free", "\n\tOriginal", "\n\tWheat"};
- total.add("\nDough: ");
- total.add(Doughs[DoughRandom]);
- }
- public void Base()
- {
- int BaseRandom=rand.nextInt(3);
- String[] Bases = {"\n\tHerb Butter", "\n\tOlive Oil", "\n\tButter"};
- total.add("\nBase: ");
- total.add(Bases[BaseRandom]);
- }
- public void Sauce()
- {
- int SauceRandom1=rand.nextInt(5);
- String[] Sauces = {"\n\tAlfredo", "\n\tRed", "\n\tBBQ", "\n\tBuffalo", "\n\tPesto"};
- total.add("\nSauce: ");
- total.add(Sauces[SauceRandom1]);
- }
- public void Cheese()
- {
- HashSet<String> Cheeses1 = new HashSet<String>();
- int CheeseRandom2=rand.nextInt(6);
- String[] Cheeses = {"\n\tMozzarella", "\n\tFeta", "\n\tParmesan", "\n\tGorgonzola", "\n\tRicotta", "\n\tDaiya"};
- total.add("\nCheeses: ");
- if (CheeseRandom2==0)
- total.add("\n\tNone");
- while (CheeseRandom2>0)
- {
- int CheeseRandom1=rand.nextInt(6);
- while (Cheeses1.contains(Cheeses[CheeseRandom1]))
- CheeseRandom1=rand.nextInt(6);
- total.add(Cheeses[CheeseRandom1]);
- CheeseRandom2--;
- Cheeses1.add(Cheeses[CheeseRandom1]);
- }
- }
- public void Vegetables()
- {
- HashSet<String> Vegetables1 = new HashSet<String>();
- int VegetablesRandom2 = rand.nextInt(16);
- 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"};
- total.add("\nVegetables: ");
- if (VegetablesRandom2==0)
- total.add("\n\tNone");
- while (VegetablesRandom2>0)
- {
- int VegetablesRandom1=rand.nextInt(16);
- while (Vegetables1.contains(Vegetables[VegetablesRandom1]))
- VegetablesRandom1=rand.nextInt(16);
- total.add(Vegetables[VegetablesRandom1]);
- VegetablesRandom2--;
- Vegetables1.add(Vegetables[VegetablesRandom1]);
- }
- }
- public void Meats()
- {
- HashSet<String> Meats1 = new HashSet<String>();
- int MeatsRandom2 = rand.nextInt(7);
- String[] Meats = {"\n\tPepperoni", "\n\tSausage", "\n\tMeatball", "\n\tChicken", "\n\tSpicy Chicken", "\n\tHam", "\n\tBacon"};
- total.add("\nMeats: ");
- if (MeatsRandom2==0)
- total.add("\n\tNone");
- while(MeatsRandom2>0)
- {
- int MeatsRandom1=rand.nextInt(7);
- while (Meats1.contains(Meats[MeatsRandom1]))
- MeatsRandom1=rand.nextInt(7);
- total.add(Meats[MeatsRandom1]);
- MeatsRandom2--;
- Meats1.add(Meats[MeatsRandom1]);
- }
- }
- public void AfterBakes()
- {
- HashSet<String> AfterBakes1 = new HashSet<String>();
- int AfterBakesRandom2 = rand.nextInt(6);
- String[] AfterBakes = {"\n\tBBQ", "\n\tPesto", "\n\tRanch", "\n\tRed Sauce", "\n\tBasil", "\n\tBuffalo"};
- total.add("\nAfterbakes: ");
- if (AfterBakesRandom2==0)
- total.add("\n\tNone");
- while(AfterBakesRandom2>0)
- {
- int AfterBakesRandom1=rand.nextInt(6);
- while(AfterBakes1.contains(AfterBakes[AfterBakesRandom1]))
- AfterBakesRandom1=rand.nextInt(6);
- total.add(AfterBakes[AfterBakesRandom1]);
- AfterBakesRandom2--;
- AfterBakes1.add(AfterBakes[AfterBakesRandom1]);
- }
- }
- public ArrayList<String> GiveArray()
- {
- return total;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement