-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
151 lines (138 loc) · 7.03 KB
/
Copy pathMain.java
File metadata and controls
151 lines (138 loc) · 7.03 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import java.util.Scanner;
/**
* PASO 4: Clase Main
*
* Menú interactivo del restaurante
*/
public class Main {
public static void main(String[] args) {
// PASO 4.1: Inicialización
// TODO: Restaurante restaurante = new Restaurante();
// TODO: restaurante.cargarMenu();
// TODO: Scanner scanner = new Scanner(System.in);
// TODO: boolean salir = false;
// TODO: Pedido pedidoActual = null;
// PASO 4.2: Menú principal
// TODO: while (!salir) {
// TODO: System.out.println("\n=== RESTAURANTE ONLINE ===");
// TODO: System.out.println("1. Ver menú completo");
// TODO: System.out.println("2. Ver por categoría");
// TODO: System.out.println("3. Nuevo pedido");
// TODO: System.out.println("4. Agregar al pedido");
// TODO: System.out.println("5. Ver pedido actual");
// TODO: System.out.println("6. Eliminar del pedido");
// TODO: System.out.println("7. Confirmar pedido");
// TODO: System.out.println("8. Ver pedidos pendientes");
// TODO: System.out.println("9. Generar cuenta");
// TODO: System.out.println("10. Cambiar estado pedido");
// TODO: System.out.println("11. Salir");
// TODO: System.out.print("Elige: ");
// PASO 4.3: Switch
// TODO: try {
// TODO: int opcion = Integer.parseInt(scanner.nextLine());
// TODO: switch (opcion) {
// TODO: case 1: verMenu(restaurante); break;
// TODO: case 2: verPorCategoria(restaurante, scanner); break;
// TODO: case 3: pedidoActual = restaurante.crearPedido(); break;
// TODO: case 4: agregarAlPedido(restaurante, scanner, pedidoActual); break;
// TODO: case 5: verPedidoActual(pedidoActual); break;
// TODO: case 6: eliminarDelPedido(pedidoActual, scanner); break;
// TODO: case 7: pedidoActual = confirmarPedido(restaurante, pedidoActual); break;
// TODO: case 8: restaurante.mostrarPedidosPendientes(); break;
// TODO: case 9: generarCuenta(restaurante, scanner); break;
// TODO: case 10: cambiarEstado(restaurante, scanner); break;
// TODO: case 11: salir = true; System.out.println("👋 Buen provecho"); break;
// TODO: default: System.out.println("❌ Opción no válida");
// TODO: }
// TODO: } catch (NumberFormatException e) {
// TODO: System.out.println("❌ Debes ingresar un número");
// TODO: }
// TODO: }
// TODO: scanner.close();
}
// Métodos auxiliares
// TODO: private static void verMenu(Restaurante restaurante) {
// TODO: restaurante.mostrarMenu();
// TODO: }
// TODO: private static void verPorCategoria(Restaurante restaurante, Scanner scanner) {
// TODO: System.out.println("Categorías: Entrantes, Platos, Bebidas, Postres");
// TODO: System.out.print("¿Cuál? ");
// TODO: String categoria = scanner.nextLine();
// TODO: restaurante.mostrarPorCategoria(categoria);
// TODO: }
// TODO: private static void agregarAlPedido(Restaurante restaurante, Scanner scanner, Pedido pedidoActual) {
// TODO: if (pedidoActual == null) {
// TODO: System.out.println("❌ Crea un pedido primero");
// TODO: return;
// TODO: }
// TODO: System.out.print("Nombre del plato: ");
// TODO: String nombre = scanner.nextLine();
// TODO: System.out.print("Cantidad: ");
// TODO: try {
// TODO: int cantidad = Integer.parseInt(scanner.nextLine());
// TODO: restaurante.agregarAlPedido(pedidoActual, nombre, cantidad);
// TODO: } catch (NumberFormatException e) {
// TODO: System.out.println("❌ Cantidad debe ser un número");
// TODO: } catch (IllegalArgumentException e) {
// TODO: System.out.println("❌ " + e.getMessage());
// TODO: }
// TODO: }
// TODO: private static void verPedidoActual(Pedido pedidoActual) {
// TODO: if (pedidoActual == null) {
// TODO: System.out.println("❌ No hay pedido activo");
// TODO: } else {
// TODO: pedidoActual.verPedido();
// TODO: System.out.println("Subtotal: " + String.format("%.2f", pedidoActual.calcularSubtotal()) + "€");
// TODO: }
// TODO: }
// TODO: private static void eliminarDelPedido(Pedido pedidoActual, Scanner scanner) {
// TODO: if (pedidoActual == null) {
// TODO: System.out.println("❌ No hay pedido activo");
// TODO: return;
// TODO: }
// TODO: pedidoActual.verPedido();
// TODO: System.out.print("Índice a eliminar: ");
// TODO: try {
// TODO: int index = Integer.parseInt(scanner.nextLine());
// TODO: pedidoActual.eliminarItem(index);
// TODO: } catch (NumberFormatException e) {
// TODO: System.out.println("❌ Índice debe ser un número");
// TODO: }
// TODO: }
// TODO: private static Pedido confirmarPedido(Restaurante restaurante, Pedido pedidoActual) {
// TODO: if (pedidoActual == null) {
// TODO: System.out.println("❌ No hay pedido activo");
// TODO: return null;
// TODO: }
// TODO: try {
// TODO: restaurante.confirmarPedido(pedidoActual);
// TODO: return null; // Pedido confirmado, empieza uno nuevo
// TODO: } catch (IllegalArgumentException e) {
// TODO: System.out.println("❌ " + e.getMessage());
// TODO: return pedidoActual;
// TODO: }
// TODO: }
// TODO: private static void generarCuenta(Restaurante restaurante, Scanner scanner) {
// TODO: System.out.print("ID del pedido: ");
// TODO: try {
// TODO: int id = Integer.parseInt(scanner.nextLine());
// TODO: System.out.print("Propina (%)? (0 si no hay): ");
// TODO: double propina = Double.parseDouble(scanner.nextLine());
// TODO: restaurante.generarCuenta(id, propina);
// TODO: } catch (NumberFormatException e) {
// TODO: System.out.println("❌ Ingresa números válidos");
// TODO: }
// TODO: }
// TODO: private static void cambiarEstado(Restaurante restaurante, Scanner scanner) {
// TODO: System.out.print("ID del pedido: ");
// TODO: try {
// TODO: int id = Integer.parseInt(scanner.nextLine());
// TODO: System.out.println("Estados: pendiente, en_prep, listo");
// TODO: System.out.print("Nuevo estado: ");
// TODO: String estado = scanner.nextLine();
// TODO: restaurante.cambiarEstadoPedido(id, estado);
// TODO: } catch (NumberFormatException e) {
// TODO: System.out.println("❌ ID debe ser un número");
// TODO: }
// TODO: }
}