-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPersona.cpp
97 lines (88 loc) · 2.32 KB
/
Persona.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
/*Universidad de las Fuerzas Armadas ESPE
Autores: Shakira Cofre, Guillermo Casanova, Esteban Molina
Fecha de creación: 15-10-2018 Fecha de modificación: 15-10-2018
Problema: Verificar un número de cédula de una persona que es un estudiante y sacar el promedio de sus notas.*/
#include "Persona.h"
#include <iostream>
#include <string>
using namespace std;
//desarrollo de la clase persona
Persona::Persona(char ci[], string nom, string ape){
strcpy(cedula, ci);
nombre=nom;
apellido=ape;
}
Persona::Persona(){
}
void Persona::setCedula(char ci[]){
strcpy(cedula, ci);
}
void Persona::setNombre(string nom){
nombre=nom;
}
void Persona::setApellido(string ape){
apellido=ape;
}
// desarrollo los metodos get
string Persona::getCedula(){
return cedula;
}
string Persona::getNombre(){
return nombre;
}
string Persona::getApellido(){
return apellido;
}
//desarrollo del metodo mostrar persona
void Persona::pedirDatosPersona(){
int bandera=0;
cout<<"Ingrese el nombre"<<endl;
cin>>nombre;
cout<<"Ingrese el apellido"<<endl;
cin>>apellido;
cout<<"Ingrese su cedula"<<endl;
cin>>cedula;
for(int i=0;i<=10;i++){
int aux = cedula[i];
if(aux < 47 || aux > 57){
bandera = 1;
}
}
while(strlen(cedula) > 10 || bandera == 1 || !this->verificarCedula(cedula)){
cout << "Ingrese la cedula de " << nombre << " " << apellido << ": ";
cin >> cedula;
bandera = 0;
for(int j = 0; j < 10; j++){
int aux = cedula[j];
if(aux < 47 || aux > 57){
bandera = 1;
}
}
}
}
void Persona::mostrarDatosPersona(){
setlocale(LC_ALL,"");
cout<<"\n"<<"Cédula: "<<cedula<<" Nombre: "<<nombre<<" Apellido: "<<apellido<<endl;
}
bool Persona::verificarCedula(char _cedula[]){
int suma = 0, aux, decena = 10;
for(int i = 0; i < 9; i++){
aux = _cedula[i] - 48;
if(i == 0 || i == 2 || i == 4 || i == 6 || i == 8){
aux = aux * 2;
if (aux >= 10){
aux = aux - 9;
}
}
suma = suma + aux;
}
while (decena < suma){
decena = decena + 10;
}
int digitoVerificador = _cedula[9] - 48;
if(digitoVerificador == (decena - suma)){
return true;
}else{
return false;
}
}