Skip to content

Instantly share code, notes, and snippets.

@muzafakar
Created July 7, 2018 05:11
Show Gist options
  • Save muzafakar/7aa78b1d93e2189d05486137b94c5992 to your computer and use it in GitHub Desktop.
Save muzafakar/7aa78b1d93e2189d05486137b94c5992 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class Nasabah{
private : int saldo;
public:
Nasabah(){
saldo = 1500000;
}
void setSaldo(int s){
saldo = saldo;
}
int getSaldo(){
return saldo;
}
void tambahSaldo(int s){
saldo += s;
}
void ambilUang(int s){
saldo -= s;
}
void transferUang(int s, int r){
saldo -=s;
cout << s << " berhasil ditransfer ke: " << r << endl;
}
};
Nasabah bowo;
bool login();
void mainMenu();
void cekSaldo();
void setorUang();
void ambilUang();
void transferUang();
int logout();
int main()
{
initiate:
if(login()){
mainMenu();
}else{
system("clear");
cout << "something wrong" << endl;
goto initiate;
}
}
bool login(){
initiateLogin:
string username, password;
bool isLogin;
cout << "========LOGIN=========" << endl;
cout << "username: "; cin >> username;
cout << "password: "; cin >> password;
cout << "======================" << endl;
(username == "bowo" && password == "uunc") ? isLogin = true: isLogin = false;
bowo.setSaldo(1500000);
return isLogin;
}
void mainMenu(){
system("clear");
int choice;
cout << "======================" << endl;
cout << "1.Cek saldo" << endl;
cout << "2.Setor uang" << endl;
cout << "3.Ambil uang" << endl;
cout << "4.Transfer uang" << endl;
cout << "5.Logout" << endl;
cout << "======================" << endl;
cout << "pilihan: "; cin >> choice;
switch(choice){
case 1:
cekSaldo();
break;
case 2:
setorUang();
break;
case 3:
ambilUang();
break;
case 4:
transferUang();
break;
case 5:
logout();
break;
default:
mainMenu();
break;
}
}
void cekSaldo(){
system("clear");
char b;
cout << "======================" << endl;
cout << "Saldo anda Rp." << bowo.getSaldo() << endl;
cout << "\nTekan B untuk kembali" << endl;
cin >> b;
if(b == 'b' || b == 'B'){
mainMenu();
}
}
void setorUang(){
int uang;
char b, validation;
system("clear");
cout << "======================" << endl;
cout << "Jumlah uang yang disetorkan:" << endl;
cin >> uang;
cout << "[y] yes [c] cancel" << endl;
cin >> validation;
if(validation == 'y' || validation == 'Y'){
bowo.tambahSaldo(uang);
}else if(validation == 'c' || validation == 'C'){
mainMenu;
}
cout << "\nTekan B untuk kembali" << endl;
cin >> b;
if(b == 'b' || b == 'B'){
mainMenu();
}
}
void ambilUang(){
int uang;
char b, validation;
system("clear");
cout << "======================" << endl;
cout << "Jumlah uang yang diambil:" << endl;
cin >> uang;
cout << "[y] yes [c] cancel" << endl;
cin >> validation;
if(validation == 'y' || validation == 'Y'){
bowo.ambilUang(uang);
}else if(validation == 'c' || validation == 'C'){
mainMenu();
}
cout << "\nTekan B untuk kembali" << endl;
cin >> b;
if(b == 'b' || b == 'B'){
mainMenu();
}
}
void transferUang(){
int uang, noRekening;
char b, validation;
system("clear");
cout << "======================" << endl;
cout << "Nomor rekening tujuan:" << endl;
cin >> noRekening;
cout << "Jumlah uang yang ditransfer:" << endl;
cin >> uang;
cout << "[y] yes [c] cancel" << endl;
cin >> validation;
if(validation == 'y' || validation == 'Y'){
bowo.transferUang(uang, noRekening);
}else if(validation == 'c' || validation == 'C'){
mainMenu();
}
cout << "\nTekan B untuk kembali" << endl;
cin >> b;
if(b == 'b' || b == 'B'){
mainMenu();
}
}
int logout(){
system("clear");
return 0;
}
@AqsaFiqhi
Copy link

thanks mas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment