-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
83 lines (71 loc) · 2.57 KB
/
App.java
File metadata and controls
83 lines (71 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.util.Scanner;
public class App{
static Coffee coffee = new Coffee( 400, 540, 120, 10 , 500);
final static Scanner scanner = new Scanner(System.in);
static void elegirCafe(){
String elegirCafe;
TipoCafe tipoCafe;
do {
System.out.println("Elegir tipo cafe : 1 - Espresso, 2 - Latte, 3 - Cappuccino, regresar - a menu principal");
elegirCafe = scanner.next();
if(elegirCafe.equals("regresar")){
return;
}
tipoCafe = TipoCafe.encontrarPorId(Integer.parseInt(elegirCafe));
switch (tipoCafe) {
case ESPRESSO:
Coffee espresso = new Espresso();
coffee.prepararCafe(espresso);
break;
case LATTE:
Coffee latte = new Latte();
coffee.prepararCafe(latte);
break;
case CAPPUCINO:
Coffee Cappuccino = new Cappuccino();
coffee.prepararCafe(Cappuccino);
break;
default:
break;
}
} while (tipoCafe.name().equals("NOT_FOUND"));
}
static void llenarIngredientes(){
System.out.println("Ingresar cantidad de agua");
int water = scanner.nextInt();
System.out.println("Ingresar cantidad de leche");
int milk = scanner.nextInt();
System.out.println("Ingresar cantidad de granos de cafe");
int coffeeBains = scanner.nextInt();
System.out.println("Ingresar cantidad de vasos");
int cups = scanner.nextInt();
coffee.llenarCafetera(water, milk, coffeeBains, cups);
}
public static void main(String[] args){
System.out.println(coffee.toString());
String opcion;
do {
System.out.println("Escribir accion a realizar : comprar, llenar, retirar, verificar, salir");
opcion = scanner.next();
switch(opcion){
case "comprar":
elegirCafe();
break;
case "llenar":
llenarIngredientes();
break;
case "retirar":
coffee.takeMoney();
break;
case "verificar":
System.out.println(coffee.toString());
break;
case "salir":
break;
default:
System.out.println("Opcion no valida");
}
} while (!opcion.equals("salir"));
System.out.println(coffee.toString());
}
}