/* --- main.cpp --- */
#include <iostream>
#include <cstdlib>
#include "tctacte.h"
using namespace std;
int main()
{
TCtaCte cuenta(1200.00);
float monto;
unsigned int opc = 0;
bool flag_salir = false;
do
{
system("CLS");
cout << "Bienvenido al sistema de Home Banking" << endl << "----------------------------------------" << endl
<< "Para realizar una operacion, siga las instrucciones." << endl
<< "Opcion 1: Consulta de saldo" << endl
<< "Opcion 2: Consulta de la cantidad de extracciones" << endl
<< "Opcion 3: Realizar deposito" << endl
<< "Opcion 4: Realizar extraccion" << endl
<< "Opcion 5: Salir" << endl;
cout << "Opcion elegida: ";
cin >> opc;
cout << endl;
while(opc > 5 || opc < 1)
{
cout << "Opcion elegida: ";
cin >> opc;
}
switch(opc)
{
case 1:
{
cout << "Consulta de saldo: " << cuenta.get_saldo() << endl;
system("PAUSE>NULL");
break;
}
case 2:
{
cout << "Consulta de cantidad de extracciones: " << cuenta.get_cant_ext() << endl;
system("PAUSE>NULL");
break;
}
case 3:
{
cout << "Ingrese el deposito que desea realizar: ";
cin >> monto;
cout << "Saldo de cuenta actual: " << cuenta.depositar(monto) << endl;
system("PAUSE>NULL");
break;
}
case 4:
{
cout << "Ingrese la extraccion que desea realizar: ";
cin >> monto;
if(cuenta.extraer(monto))
cout << "Saldo de cuenta actual: " << cuenta.get_saldo() << endl;
else
cout << "Operacion invalida, no cuenta con el suficiente saldo en su cuenta" << endl;
system("PAUSE>NULL");
break;
}
case 5:
{
flag_salir = true;
break;
}
}
}
while(!flag_salir);
return 0;
}
/* --- tctacte.h --- */
#ifndef TCTACTE_H
#define TCTACTE_H
class TCtaCte
{
private:
/* Atributos privados */
float saldo;
unsigned int cant_ext;
public:
/* Métodos públicos */
TCtaCte(float deposito_inicial = 0);
float get_saldo();
unsigned int get_cant_ext();
void set_saldo(float monto);
void set_cant_ext(unsigned int ut_ext);
float depositar(float monto);
bool extraer(float monto);
~TCtaCte();
};
#endif // TCTACTE_H
/* --- tctacte.cpp --- */
#include "tctacte.h"
#define COBRO_EXTRACCIONES 5.00
TCtaCte::TCtaCte(float deposito_inicial)
{
cant_ext = 0;
saldo = deposito_inicial;
}
/* Métodos privados */
float TCtaCte::get_saldo()
{
return saldo;
}
unsigned int TCtaCte::get_cant_ext()
{
return cant_ext;
}
void TCtaCte::set_saldo(float monto)
{
saldo = monto;
}
void TCtaCte::set_cant_ext(unsigned int u_ext)
{
cant_ext = u_ext;
}
/* Métodos públicos */
float TCtaCte::depositar(float monto)
{
saldo += monto;
return saldo;
}
bool TCtaCte::extraer(float monto)
{
if(saldo < monto || saldo <= 0)
return false;
else
{
cant_ext++;
if(cant_ext > 5)
saldo -= monto + COBRO_EXTRACCIONES;
else
saldo -= monto;
return true;
}
}
TCtaCte::~TCtaCte()
{
}
Comments