-
Notifications
You must be signed in to change notification settings - Fork 0
/
Residente.cpp
133 lines (104 loc) · 2.85 KB
/
Residente.cpp
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
#include <iostream>
#include <cstring>
#include "Utilidades.h"
#include "Persona.h"
#include "Fecha.h"
#include "Residente.h"
using namespace std;
Residente::Residente() {
}
int Residente::getUnidad() const {
return _unidad;
}
string Residente::getIngreso() {
string retornar = _ingreso.toString();
return retornar;
}
bool Residente::getPropietario_Inquilino() const {
return _propietario_inquilino;
}
void Residente::setUnidad(int unidad) {
_unidad = unidad;
}
void Residente::setIngreso(int dia, int mes, int anio) {
_ingreso.cargar(dia, mes, anio);
}
void Residente::setPropietario_Inquilino(bool propietario) {
_propietario_inquilino = propietario;
}
void Residente::cargarResidente() {
Utilidades util;
cargarPersona(1);
int unidad;
int dia, mes, anio;
int propie;
cout << "Ingrese Unidad correspondiente a asignar 1-200 : " << endl;
cin >> unidad;
//unidad 0 solo emp y prov
util.validarInt(unidad);
while (unidad < 1 || unidad >200) {
cout << "Unidad invalida . Recuerde que la Unidad 0 corresponde a Empleados y Proveedores." << endl;
cin >> unidad;
util.validarInt(unidad);
}
setUnidad(unidad);
cout << "Ingrese anio de Ingreso 2022- 2030 : " << endl;
cin >> anio;
util.validarInt(anio);
while (anio < 2022 || anio > 2030) {
cout << "Anio Invalido " << endl;
cin >> anio;
util.validarInt(anio);
}
cout << "Ingrese mes de Ingreso : " << endl;
cin >> mes;
util.validarInt(mes);
util.validarMes(mes);
cout << "Ingrese dia de Ingreso : " << endl;
cin >> dia;
util.validarInt(dia);
while (!util.validarDia(dia, mes, anio)) {
cout << "Dia de Ingreso invalido, ingrese nuevamente : " << endl;
cin >> dia;
util.validarInt(dia);
}
setIngreso(dia, mes, anio);
cout << "Ingrese 1 si es Residente ( Propietario ) , Ingrese 0 si es Inquilino (Alquila) " << endl;
cin >> propie;
util.validarInt(propie);
while (propie <0 || propie > 1 ) {
cout << "Dato invalido, ingrese nuevamente" << endl;
cin >> propie;
util.validarInt(propie);
}
if (propie == 1) {
setPropietario_Inquilino(true);
}
else {
setPropietario_Inquilino(false);
}
}
string Residente::mostrarResidentestring() {
string retornar = mostrarPersonastring();
if (getPropietario_Inquilino()) {
retornar += "Unidad del Residente : " + to_string(getUnidad()) + "\n"
+ " Fecha de Ingreso del Residente : " + getIngreso();
}
else {
retornar += "Unidad del Inquilino : " + to_string(getUnidad()) + "\n"
+ " Fecha de Ingreso del Inquilino : " + getIngreso();
}
return retornar;
}
void Residente::mostrar() {
mostrarPersona();
if (getPropietario_Inquilino()) {
cout << "Unidad del Residente : " << getUnidad()<< endl;
cout << "Fecha de Ingreso del Residente : " << getIngreso() << endl;
}
else {
cout << "Unidad del Inquilino : " << getUnidad() << endl;
cout << "Fecha de Ingreso del Inquilino : " << getIngreso() << endl;
}
cout << endl;
}