//Chan Tak Sang //50929220 #include#include #include using namespace std; class bankaccount { friend bool loginchecking(string x, string y, bankaccount z[10]); public: bankaccount(); void option(); void balancechecking(); void passwordreset(); void withdraw(); void deposit(); void transfer(); private: string accountnumber; string password; double balance; }; void accountnogen(string& str); bool loginchecking(string x, string y, bankaccount z[10]) { int i; for (i=0; i<10; i++) { if ((z[i].accountnumber == x) && (z[i].password == y)) return true; } return false; } bankaccount::bankaccount() { string x; balance = 0; password = "000000"; accountnogen(x); accountnumber = x; } void accountnogen(string& str) //accountnogen { static int seed = 1200; char buffer[10]; string str1 = "300-475-"; string str2(itoa(seed++, buffer, 10)); str = str1 + str2; } void bankaccount::withdraw() { int wd; cout << "Withdraw: "; cin >> wd; if (wd > balance) cout << "Insufficient fund"; else balance = balance - wd; cout << "$" << balance << "has been withdrawn from your account"; } void bankaccount::balancechecking() { int bal; bal = balance; cout << "Balance:$" << balance; } void bankaccount::deposit() { int dp; cout <<"Deposit: "; cin >> dp; balance = balance + dp; cout << "$" << balance << "has been withdrawn from your account"; } void bankaccount::transfer() { string transfertarget; double transferamount; cout << "Transfer to: "; getline(cin, transfertarget); cin >> transferamount; if (transfertarget == accountnumber) void close(); } void main() { bankaccount customer[10]; cout << "Account number: "; string accno; string pw; cin >> accno; cout << "Password: "; cin >> pw; if (loginchecking(accno, pw, customer)) { cout << "Welcome " << accno < > optiontype; while (optiontype != 'q') { switch (optiontype) { case 'c' : customer.balancechecking(); break; case 'r' : void passwordreset(); break; case 'w' : void withdraw(); break; case 'd' : void deposit(); break; case 't' : void transfer(); break; } } main(); } else cout << "Invalid account number."; }
Text file Source (historic): geocities.com/hk/crazysang1223/cs2331
geocities.com/hk/crazysang1223geocities.com/hk
(to report bad content: archivehelp @ gmail)
|
|
|
|
|