forked from mouredev/roadmap-retos-programacion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedalmava.pas
130 lines (117 loc) · 3.06 KB
/
edalmava.pas
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
program Enumerado;
Uses Crt;
type
DiasSemana = (Lunes, Martes, Miercoles, Jueves, Viernes, Sabado, Domingo);
EstadoPedido = (PENDIENTE, ENVIADO, ENTREGADO, CANCELADO);
Pedido = object
private
id : Integer;
estado : EstadoPedido;
public
constructor Iniciar(Identificador: Integer);
procedure EnviarPedido;
procedure EntregarPedido;
procedure CancelarPedido;
procedure MostrarEstadoPedido;
end;
var
Dia: DiasSemana;
numDia: Byte;
pedido1, pedido2, pedido3, pedido4: Pedido;
ids : String;
constructor Pedido.Iniciar(Identificador: Integer);
begin
id := Identificador;
estado := PENDIENTE
end;
procedure Pedido.EnviarPedido();
begin
if estado = PENDIENTE then
begin
estado := ENVIADO;
Str(id, ids); WriteLn('Pedido ' + ids + ' Enviado')
end
else
WriteLn('No se puede enviar el pedido')
end;
procedure Pedido.EntregarPedido();
begin
if estado = ENVIADO then
begin
estado := ENTREGADO;
Str(id, ids); WriteLn('Pedido ' + ids + ' Entregado')
end
else
WriteLn('No se puede entregar un pedido que no se ha enviado')
end;
procedure Pedido.CancelarPedido();
begin
if estado = ENTREGADO then
Writeln('No se puede cancelar el pedido porque ya fue entregado')
else
begin
estado := CANCELADO;
Str(id, ids); WriteLn('Pedido ' + ids + ' Cancelado')
end
end;
procedure Pedido.MostrarEstadoPedido();
begin
Str(id, ids);
Write('Pedido ' + ids);
case estado of
PENDIENTE: Writeln(' : Pendiente');
ENVIADO: WriteLn(' : Enviado');
ENTREGADO: WriteLn(' : Entregado');
CANCELADO: WriteLn(' : Cancelado');
end;
end;
function getDia(const dia: Byte):DiasSemana;
begin
getDia := DiasSemana(dia - 1);
end;
begin
ClrScr();
Write('Digite el numero del dia: ');
ReadLn(numDia);
if not (numDia in [1, 2, 3, 4, 5, 6, 7]) then
begin
WriteLn('El numero debe ser un numero entre 1 y 7');
exit
end;
Dia := getDia(numDia);
Write('Corresponde a: ');
case Dia of
Lunes: Writeln('Lunes');
Martes: Writeln('Martes');
Miercoles: Writeln('Miercoles');
Jueves: Writeln('Jueves');
Viernes: Writeln('Viernes');
Sabado: Writeln('Sabado');
Domingo: Writeln('Domingo');
end;
Writeln('');
WriteLn('Reto Extra');
Delay(1000);
WriteLn('');
WriteLn('Iniciando Pedidos');
pedido1.Iniciar(101);
pedido2.Iniciar(102);
pedido3.Iniciar(103);
pedido4.Iniciar(104);
WriteLn('');
WriteLn('Movimiento de Pedidos');
pedido1.EnviarPedido();
pedido2.EnviarPedido();
pedido3.EntregarPedido();
pedido4.EntregarPedido();
pedido1.EntregarPedido();
pedido2.EntregarPedido();
pedido3.CancelarPedido();
pedido1.CancelarPedido();
WriteLn('');
WriteLn('Tras realizar movimientos');
pedido1.MostrarEstadoPedido();
pedido2.MostrarEstadoPedido();
pedido3.MostrarEstadoPedido();
pedido4.MostrarEstadoPedido();
end.