/
CPasajero.cs
126 lines (108 loc) · 3.23 KB
/
CPasajero.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dominio
{
public class CPasajero
{
#region ATRIBUTOS
public List<Pasajero> pasajeros = new List<Pasajero>();
#endregion
#region SINGLETON
private static CPasajero instancia;
public static CPasajero Instancia
{
get
{
if (CPasajero.instancia == null)
{
instancia = new CPasajero();
}
return CPasajero.instancia;
}
}
private CPasajero() { }
#endregion
#region ALTA PASAJERO
public bool AltaPasajero(string nombre, string apellido, string documento)
{
bool ret = false;
if (Pasajero.ValidoCi(documento))
{
if (Pasajero.ValidoNombre(nombre))
{
if (Pasajero.ValidoApellido(apellido))
{
Pasajero aux = BuscarPasajeroPorDoc(documento);
if (aux == null)
{
ret = true;
aux = new Pasajero(nombre, apellido, documento);
}
}
}
}
return ret;
}
#endregion
#region MODIFICACION PASAJERO
public bool ModificacionPasajero(string nombre, string apellido, string documento, int puntaje, int id)
{
bool ret = false;
if (Pasajero.ValidoCi(documento))
{
if (Pasajero.ValidoNombre(nombre))
{
if (Pasajero.ValidoApellido(apellido))
{
if (Pasajero.ValidoPuntaje(puntaje))
{
Pasajero aux = BuscarPasajeroPorId(id);
if (aux != null)
{
aux.Modificacion(nombre, apellido, documento, puntaje);
ret = true;
}
}
}
}
}
return ret;
}
#endregion
#region BUSCAR PASAJERO POR ID
public Pasajero BuscarPasajeroPorId(int id)
{
Pasajero aux = null;
int i = 0;
while (i < this.pasajeros.Count && aux != null)
{
if (this.pasajeros[i].Id == id)
{
aux = this.pasajeros[i];
}
i++;
}
return aux;
}
#endregion
#region BUSCAR PASAJERO POR DOCUMENTO
public Pasajero BuscarPasajeroPorDoc(string doc)
{
Pasajero aux = null;
int i = 0;
while (i < this.pasajeros.Count && aux != null)
{
if (this.pasajeros[i].Documento == doc)
{
aux = this.pasajeros[i];
}
i++;
}
return aux;
}
#endregion
}
}