Created
May 18, 2021 00:01
-
-
Save Lesliecalvillo/62a61d4893cb492f4840b3bcca07c7c5 to your computer and use it in GitHub Desktop.
POO Act12 clase persona
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
//Declaracion de la clase | |
class LeslieCalvillo | |
{ | |
public: | |
void dormir(); | |
void hablar(); | |
void contar(); | |
void adquirirNombre(); | |
void decirNombre(); | |
private: | |
char nombre[48]; | |
};//fin de LeslieCalvillo | |
void LeslieCalvillo::dormir(){ | |
cout<<"ZZZZzzzzzzzzz......."<<endl; | |
}//fin de dormir | |
void LeslieCalvillo::hablar(){ | |
cout<<"bla bla bla...."<<endl; | |
};//fin de hablar | |
void LeslieCalvillo::contar(){ | |
cout<<"1+1 e igual a 2..."<<endl; | |
};//fin de contar | |
void LeslieCalvillo::adquirirNombre(){ | |
cout<<"ingrese nombre= "<<endl; | |
cin>>nombre; | |
};//fin de adquirir nombre | |
void LeslieCalvillo::decirNombre(){ | |
cout<<"mi nombre es "<<nombre<<endl; | |
};//fin de decirNombre | |
int main() | |
{ | |
int respuesta = 0; | |
// Creando una persona y capturando su nombre | |
cout << "Desea crear una persona? 1=Si, 0=No: "; | |
cin >> respuesta; | |
if (respuesta == 1) | |
{ | |
LeslieCalvillo p; | |
p.adquirirNombre(); | |
// si el usuario lo desea la persona puede decir su nombre | |
cout << "Desea que diga mi nombre? 1=Si, 0=No: "; | |
cin >> respuesta; | |
if (respuesta == 1) | |
{ | |
p.decirNombre(); | |
} | |
// El usuario decide si la persona habla | |
cout << "Quiere escucharme hablar? 1=Si, 0=No: "; | |
cin >> respuesta; | |
if (respuesta == 1) | |
{ | |
p.hablar(); | |
} | |
cout << "Desea que vaya a dormir? 1=Si, 0=No: "; | |
cin >> respuesta; | |
if (respuesta == 1) | |
{ | |
p.dormir(); | |
} | |
cout << "Desea oirme contar? 1=Si, 0=No: "; | |
cin >> respuesta; | |
if (respuesta == 1) | |
{ | |
p.contar(); | |
} | |
} | |
cout<<"Hecho por leslie calvillo 190260012-9"<<endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment