Created
January 14, 2018 14:07
-
-
Save Artoria2e5/ee4b42b6cc89d53c8146367bf4ef1e70 to your computer and use it in GitHub Desktop.
CurlyFakePolyp created by Artoria2e5 - https://repl.it/@Artoria2e5/CurlyFakePolyp
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 <cassert> | |
#include <cctype> | |
#include <climits> | |
#include <cmath> | |
#include <cstring> | |
#include <fstream> | |
#include <iomanip> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
/// Llamadas de funnciones | |
struct account { | |
int bal; | |
}; | |
struct user { | |
account ahorro; | |
account cheque; | |
int username; | |
int pin; | |
}; | |
// FIXME: username currently serves as a "first password". | |
// We can use a map (unordered_map) to construct a dictionary | |
// so we can look up the user struct with a username. | |
user camarada{ | |
{4560}, // ahorro | |
{1917}, // cheque | |
4321, // username | |
1234 // pin | |
}; | |
/// Declaracion | |
// (will be copied from code later) | |
// Hola -> Login -> Menu (ahorro/cheque) -> Transacciones -> Dep/Ret/Disp | |
void Hola(user&); | |
bool Login(user&); | |
// file output | |
ofstream salida; | |
// FIXME: not "lad" | |
void Hola(user &lad) { | |
int choose; | |
do { | |
cout << " LOGIN" << endl; | |
cout << " 1: Login " << endl; | |
cout << " 2: Salir " << endl; | |
cin >> choose; | |
switch (choose) { | |
case 1: | |
Login(user); | |
break; | |
default:; | |
} | |
} while (choose != 2); | |
return; | |
} | |
bool Login(user &lad) { | |
int Attemp = 0; | |
int username; | |
int pin; | |
// camarada: name 4321, pin 1234 | |
cout << "Inserte el nombre de usuario." << endl; | |
cin >> username; | |
while (username != lad.username && Attemp < 3) { | |
cout << "Error, inserte nuevamente el nombre de usuario" << endl; | |
cin >> username; | |
Attemp++; | |
} | |
if (Attemp == 3) { | |
cout << "Se acabaron los intentos." << endl; | |
// FIXME | |
salida << "cops called, nombre de usuario." << endl; | |
return (false); | |
} | |
cout << "Inserte el Pin." << endl; | |
cin >> pin; | |
while (pin != lad.pin && Attemp < 3) { | |
cout << "Error, inserte nuevamente el pin. " << endl; | |
cin >> Pin; | |
Attemp++; | |
} | |
if (Attemp == 3) { | |
cout << "Se acabaron los intentos del Pin" << endl; | |
// FIXME | |
salida << "cops called, pin." << endl; | |
return (Attemp != 3); | |
} | |
Menu(lad); | |
} | |
void Menu(user &lad) { | |
salida << "menu: " << lad.username << endl; | |
int Choose; | |
do { | |
cout << " Escoja el tipo de cuenta." << endl; | |
cout << " 1: Cuenta de Cheque " << endl; | |
cout << " 2: Cuenta de Ahorro " << endl; | |
cout << " 3: Salir " << endl; | |
cin >> Choose; | |
switch (Choose) { | |
case 1: | |
Transacciones(lad.cheque, s"cheque"); | |
break; | |
case 2: | |
Transacciones(lad.ahorro, s"ahorro"); | |
break; | |
default:; | |
} | |
} while (Choose != 3); | |
return; | |
} | |
void Transacciones(account &acct, const string &tipo) { | |
////Cuenta de cheque | |
salida << "trans/acct:" << tipo << endl; | |
int Choice; | |
do { | |
cout << "1: Deposito en cuenta de " << tipo << endl; | |
cout << "2: Retiro en cuenta de " << tipo << endl; | |
cout << "3: Balance de cuenta de " << tipo << endl; | |
cout << "4: Salir" << endl; | |
cin >> Choice; | |
switch (Choice) { | |
case 1: | |
Deposito(acct); | |
break; | |
case 2: | |
Retiro(acct); | |
break; | |
case 3: | |
Balance(acct); | |
break; | |
default:; | |
} | |
} while (Choice != 4); | |
return; | |
} | |
#if 0 // unused | |
// if (ChequeoDeposito(Deposito)) { | |
// cout << "Transaccion Posible" << endl; | |
// } else { | |
// cout << "Transaccion no Realizada" << endl; | |
// } | |
bool ChequeoDeposito(int Deposito) { | |
return (Deposito > 0); | |
} | |
// if (ChequeoRetiro(retiro)) { | |
// cout << "Transaccion Posible" << endl; | |
// } else { | |
// cout << "Transaccion no Realizada" << endl; | |
// } | |
bool ChequeoRetiro(int retiro) { | |
return (retiro > 0); | |
} | |
#endif | |
void Deposito(account &acct) { | |
int deposito = -1; | |
cout << "Inserte la cantidad que desea depositar: " << endl; | |
cin >> deposito; | |
while (deposito <= 0) { | |
cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl; | |
cin >> deposito; | |
} | |
acct.bal += deposito; | |
salida << "Deposito: " << deposito << "; bal =" << acct.bal << endl; | |
} | |
void Retiro(account &acct) { | |
int retiro = -1; | |
cout << "Inserte la cantidad que desea retirar: " << endl; | |
cin >> retiro; | |
while (retiro <= 0) { | |
cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl; | |
cin >> retiro; | |
} | |
acct.bal -= retiro; | |
salida << "Retiro: " << retiro << "; bal =" << acct.bal << endl; | |
} | |
void Balance(account &acct) { | |
cout << " Su balance actual es: $" << acct.bal << endl; | |
} | |
int main() { | |
salida.open("salida.txt", ios::out | ios::app | ios::binary); | |
salida << "camarada, bal1 = " << << endl; | |
Hola(camarada); | |
// Hola(castro); | |
salida << "bal1 = " << balance1 << endl; | |
<< endl; | |
salida.close(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment