Skip to content

Instantly share code, notes, and snippets.

@TrevCan
Created October 15, 2020 23:17
Show Gist options
  • Save TrevCan/31f38f9ede5e2b8ddff8b04fe942d849 to your computer and use it in GitHub Desktop.
Save TrevCan/31f38f9ede5e2b8ddff8b04fe942d849 to your computer and use it in GitHub Desktop.
public class IceCreamFactory {
//helado 5 estados:
/*
¬ sin hacer: 255(+35) ou 500 (+55)
¬ recipiente: cono(+5) ou vaso
¬ base 1: zarza, fresa, guanábana, maracuyá
¬ base 2: zarza, fresa, guanábana, maracuyá
¬ topping: chocolate(+5), mermelada
¬entrega
*/
public static void main(String[] args) {
IceCream[] iceCreams = new IceCream[10];
for (IceCream i :
iceCreams) {
i = new IceCream();
System.out.println(i);
}
}
}
class IceCream {
Volume volume;
Container container;
BaseFlavour flavour, flavour2;
Topping topping;
int price;
IceCream() {
int index =
(int) (Math.random() * (Volume.values().length - 1) * 1.5);
volume = Volume.values()[index];
index = (int) (Math.random() * Container.values().length - 1);
container = Container.values()[index];
index = (int) (Math.random() * BaseFlavour.values().length - 1);
flavour = BaseFlavour.values()[index];
index = (int) (Math.random() * BaseFlavour.values().length - 1);
flavour2 = BaseFlavour.values()[index];
index = (int) (Math.random() * Topping.values().length);
topping = Topping.values()[index];
price = volume.price + container.price + topping.price;
}
public String toString() {
return "\n-----------" + "\nIce Cream Factory" + "\n" + volume + "\n" +
container + "\n" + flavour + "\n" + flavour2
+ "\n" + topping + "\nTotal Price: " + price;
}
}
enum Volume {
A255(35),
B500(55);
int price;
Volume(int price) {
this.price = price;
}
}
enum Container {
CONE(5),
ICE_CREAM_DISH;
int price;
Container(int price) {
this.price = price;
}
Container() {
}
}
enum BaseFlavour {
ZARZA,
FRESA,
GUANABANA,
MARACUYA;
}
enum Topping {
CHOCOLATE(5),
JELLY(0);
int price;
Topping(int price) {
this.price = price;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment