-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCuenta.cs
More file actions
162 lines (140 loc) · 5.32 KB
/
Cuenta.cs
File metadata and controls
162 lines (140 loc) · 5.32 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
152
153
154
155
156
157
158
159
160
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace AppCarpooling
{
//Clase Cuenta
internal class Cuenta
{
//Atributos
public string nombre;
public uint Id;
public string email;
private string password;
public uint celular;
public string vehiculo;
//Constructor
public Cuenta(string nombre, uint id, string email, string password, uint celular, string vehiculo)
{
this.nombre = nombre;
this.password = password;
this.celular = celular;
this.Id = id;
this.email = email;
this.vehiculo = vehiculo;
}
}
//Se crea la clase Usuario de la cuál va a heredar de Cuenta
class Usuario : Cuenta
{
//Constructor
public Usuario(string nombre, uint id, string email, string password, uint celular, string vehiculo) : base(nombre, id, email, password, celular, vehiculo)
{
}
//Métodos
//Función para que el usuario pueda crear el viaje
public void ArmarViaje()
{
Viaje viaje = new Viaje();
StreamWriter sw = new StreamWriter("C:\\Users\\Juana\\OneDrive - UPB\\Documents\\POO\\AppCarpooling\\viajes.txt", true);
sw.WriteLine(nombre+"," + viaje.origen + "," + viaje.destino + "," + viaje.montoDinero + "," + viaje.estado+","+viaje.tipoPago);
sw.Close();
}
//Función donde el usuario confirma las rutas ofrecidas
public void ConfirmarViaje()
{
//Se crea un s¿arreglo de string donde se agregarán los viajes disponibles o rutas solicitadas
string[] viajesUsuarios;
viajesUsuarios = File.ReadAllLines("C:\\Users\\Juana\\OneDrive - UPB\\Documents\\POO\\AppCarpooling\\viajes.txt");
//Se lista el arreglo
Console.WriteLine("propuestas de viaje:");
int i = 0;
foreach (var item in viajesUsuarios)
{
i++;
Console.WriteLine(i + ". " + item);
}
Console.WriteLine("escriba el número del viaje que quiere confirmar:");
int numViaje = int.Parse(Console.ReadLine());
StreamWriter sw = new StreamWriter("C:\\Users\\Juana\\OneDrive - UPB\\Documents\\POO\\AppCarpooling\\viajes.txt");
StreamWriter sw2 = new StreamWriter("C:\\Users\\Juana\\OneDrive - UPB\\Documents\\POO\\AppCarpooling\\pagosPendientes.txt", true);
//Capturar excepción y eliminar la ruta seleccionada
if (numViaje > 0 && numViaje <= (viajesUsuarios.Length))
{
foreach (var linea in viajesUsuarios)
{
if (linea != viajesUsuarios[numViaje - 1])
{
sw.WriteLine(linea);
}
else sw2.WriteLine(linea);
}
}
else
{
Console.WriteLine("\nViaje no existente");
foreach (var linea in viajesUsuarios)
{
sw.WriteLine(linea);
}
}
sw.Close();
sw2.Close();
}
//Funcion para pagar los viajes confirmados
public void pagar()
{
//Arreglo de string que contendrán los viajes disponibles
string[] archivoViajes;
archivoViajes = File.ReadAllLines("C:\\Users\\Juana\\OneDrive - UPB\\Documents\\POO\\AppCarpooling\\pagosPendientes.txt");
string[] camposviajes;
short tipoPago = 0;
int i = 0;
StreamWriter sw2 = new StreamWriter("C:\\Users\\Juana\\OneDrive - UPB\\Documents\\POO\\AppCarpooling\\pagosPendientes.txt");
//Listar el arreglo
Console.WriteLine("viajes pendientes por pagar:");
foreach (string viaje in archivoViajes)
{
camposviajes = viaje.Split(',');
if (camposviajes[0].Equals(nombre))
{
i++;
Console.WriteLine(i + ". " + viaje);
}
}
uint viajePagar = Aplicacion.Preguntas("escoja el numero del viaje a pagar", 2);
//Capturar la excepción y el viaje
if (viajePagar > 0 && viajePagar <= (archivoViajes.Length))
{
foreach (var viaje in archivoViajes)
{
if (viaje != archivoViajes[viajePagar - 1])
{
sw2.WriteLine(viaje);
}
else
{
camposviajes = viaje.Split(",");
tipoPago = short.Parse(camposviajes[5]);
}
}
}
else
{
Console.WriteLine("\nViaje no existente");
foreach (var viaje in archivoViajes)
{
sw2.WriteLine(viaje);
}
sw2.Close();
}
sw2.Close();
//Capturar el pago
Pago pago = new Pago(tipoPago);
}
}
}