This code I wrote it myself but I do not get the expected output, just a message saying press enter to continue, the code is about emulating parts of an ATM.
what I expect the program to do is the constructor of the class "Cuenta1()" to automatically call and execute the class function "establecerValores()", so that establecerValores() can automatically call and execute pedirContrasenia(), so that pedirContrasenia() can call and execute mostrarMensaje() just by declaring
"Cuenta1 CuentaLuis();" within main.
//****************( "Cuenta.h " )****************
#include<string>
using namespace std;
class Cuenta1{
public:
Cuenta1();
void establecerValores( string, int, int );
string obtenerUsuario( );
int obtenerEdad();
int obtenerMonto();
void pedirContrasenia();
void mostrarMensaje();
private:
string nombreUsuario;
int edadUsuario;
int montoUsuario;
int contraseniaUsuario;
};
//****************( " end of Cuenta.h " )****************
//****************( "Cuenta.h " )****************
#include<string>
using namespace std;
class Cuenta1{
public:
Cuenta1();
void establecerValores( string, int, int );
string obtenerUsuario( );
int obtenerEdad();
int obtenerMonto();
void pedirContrasenia();
void mostrarMensaje();
private:
string nombreUsuario;
int edadUsuario;
int montoUsuario;
int contraseniaUsuario;
};
//****************( " end of Cuenta.h " )****************
To copy to clipboard, switch view to plain text mode
//****************( " Cuenta.cpp " )****************
#include<iostream>
#include"Cuenta.h"
using namespace std;
Cuenta1::Cuenta1(){
establecerValores( "Luis Alberto Sánchez M", 28, 3600 );
}
void Cuenta1::establecerValores( string nombre, int edad, int monto ){
nombreUsuario = nombre;
edadUsuario = edad;
montoUsuario = monto;
pedirContrasenia();
}
string Cuenta1::obtenerUsuario(){
return nombreUsuario;
}
int Cuenta1::obtenerEdad(){
return edadUsuario;
}
int Cuenta1::obtenerMonto(){
return montoUsuario;
}
void Cuenta1::pedirContrasenia(){
int contraseniaActual = 1988;
cout << "Por favor introduzca su contraseña : ";
cin >> contraseniaUsuario;
cout << "\n\n";
if( contraseniaUsuario == contraseniaActual )
mostrarMensaje();
if( contraseniaUsuario != contraseniaActual )
cout << "\n\n";
cout << "Usted ingreso una contraseña incorrecta se se reinicializara el sistema\n"
<< "por favor introduzca la contraseña correcta la proxima vez" << "\n\n" ;
}
void Cuenta1::mostrarMensaje(){
cout << "Bienvenido a cajeros Nature : " << obtenerUsuario() << " Edad " << obtenerEdad() << "usted tiene $ " << obtenerMonto() << "\n\n";
}
//****************( " end of cuenta.cpp " )****************
//****************( " Cuenta.cpp " )****************
#include<iostream>
#include"Cuenta.h"
using namespace std;
Cuenta1::Cuenta1(){
establecerValores( "Luis Alberto Sánchez M", 28, 3600 );
}
void Cuenta1::establecerValores( string nombre, int edad, int monto ){
nombreUsuario = nombre;
edadUsuario = edad;
montoUsuario = monto;
pedirContrasenia();
}
string Cuenta1::obtenerUsuario(){
return nombreUsuario;
}
int Cuenta1::obtenerEdad(){
return edadUsuario;
}
int Cuenta1::obtenerMonto(){
return montoUsuario;
}
void Cuenta1::pedirContrasenia(){
int contraseniaActual = 1988;
cout << "Por favor introduzca su contraseña : ";
cin >> contraseniaUsuario;
cout << "\n\n";
if( contraseniaUsuario == contraseniaActual )
mostrarMensaje();
if( contraseniaUsuario != contraseniaActual )
cout << "\n\n";
cout << "Usted ingreso una contraseña incorrecta se se reinicializara el sistema\n"
<< "por favor introduzca la contraseña correcta la proxima vez" << "\n\n" ;
}
void Cuenta1::mostrarMensaje(){
cout << "Bienvenido a cajeros Nature : " << obtenerUsuario() << " Edad " << obtenerEdad() << "usted tiene $ " << obtenerMonto() << "\n\n";
}
//****************( " end of cuenta.cpp " )****************
To copy to clipboard, switch view to plain text mode
//****************( " main.cpp " )****************
#include<iostream>
#include<cstdlib>
#include "Cuenta.h"
using namespace std;
int main(){
Cuenta1 cuentaLuis();
system("PAUSE");
return 0;
}
//****************( " end of main.cpp " )****************
//****************( " main.cpp " )****************
#include<iostream>
#include<cstdlib>
#include "Cuenta.h"
using namespace std;
int main(){
Cuenta1 cuentaLuis();
system("PAUSE");
return 0;
}
//****************( " end of main.cpp " )****************
To copy to clipboard, switch view to plain text mode
Bookmarks