-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPedido.java
More file actions
94 lines (84 loc) · 3.38 KB
/
Copy pathPedido.java
File metadata and controls
94 lines (84 loc) · 3.38 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
import java.util.ArrayList;
import java.time.LocalDateTime;
/**
* PASO 2: Clase Pedido
*
* Representa un pedido de un cliente
*/
public class Pedido {
// PASO 2.1: Atributos
// TODO: private int id;
// TODO: private ArrayList<Plato> items;
// TODO: private ArrayList<Integer> cantidades;
// TODO: private String estado; // "pendiente", "en_prep", "listo"
// TODO: private LocalDateTime fecha;
// PASO 2.2: Constructor
// PISTA: recibe id, inicializa ArrayList, estado="pendiente", fecha actual
// TODO: public Pedido(int id) {
// TODO: this.id = id;
// TODO: items = new ArrayList<>();
// TODO: cantidades = new ArrayList<>();
// TODO: estado = "pendiente";
// TODO: fecha = LocalDateTime.now();
// TODO: }
// PASO 2.3: agregarItem
// TODO: public void agregarItem(Plato p, int cantidad) throws IllegalArgumentException {
// TODO: if (cantidad <= 0) {
// TODO: throw new IllegalArgumentException("Cantidad debe ser > 0");
// TODO: }
// TODO: items.add(p);
// TODO: cantidades.add(cantidad);
// TODO: System.out.println("✅ Agregado al pedido");
// TODO: }
// PASO 2.4: verPedido
// TODO: public void verPedido() {
// TODO: if (estaVacio()) {
// TODO: System.out.println("📭 Pedido vacío");
// TODO: return;
// TODO: }
// TODO: System.out.println("=== PEDIDO #" + id + " ===");
// TODO: for (int i = 0; i < items.size(); i++) {
// TODO: Plato p = items.get(i);
// TODO: int cant = cantidades.get(i);
// TODO: System.out.println("[" + i + "] " + cant + "x " + p.getNombre() + " (" + p.getPrecio() + "€)");
// TODO: }
// TODO: }
// PASO 2.5: calcularSubtotal
// TODO: public double calcularSubtotal() {
// TODO: double subtotal = 0;
// TODO: for (int i = 0; i < items.size(); i++) {
// TODO: Plato p = items.get(i);
// TODO: int cant = cantidades.get(i);
// TODO: subtotal += p.getPrecio() * cant;
// TODO: }
// TODO: return subtotal;
// TODO: }
// PASO 2.6: cambiarEstado
// TODO: public void cambiarEstado(String nuevoEstado) {
// TODO: if (nuevoEstado.equals("pendiente") || nuevoEstado.equals("en_prep") || nuevoEstado.equals("listo")) {
// TODO: estado = nuevoEstado;
// TODO: System.out.println("✅ Estado: " + estado);
// TODO: } else {
// TODO: System.out.println("❌ Estado inválido");
// TODO: }
// TODO: }
// PASO 2.7: eliminarItem
// TODO: public void eliminarItem(int index) {
// TODO: if (index >= 0 && index < items.size()) {
// TODO: items.remove(index);
// TODO: cantidades.remove(index);
// TODO: System.out.println("✅ Eliminado");
// TODO: } else {
// TODO: System.out.println("❌ Índice inválido");
// TODO: }
// TODO: }
// PASO 2.8: estaVacio
// TODO: public boolean estaVacio() {
// TODO: return items.size() == 0;
// TODO: }
// PASO 2.9: Getters
// TODO: public int getId() { return id; }
// TODO: public String getEstado() { return estado; }
// TODO: public ArrayList<Plato> getItems() { return items; }
// TODO: public ArrayList<Integer> getCantidades() { return cantidades; }
}