1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <locale>
#include <windows.h>
using namespace std;
void creatingAccount(){
system("CLS");
string line, accountname, password;
fstream inFile;
inFile.open("exam.txt");
getline(inFile, line);
cout << "Enter the desired account name: "; cin >> accountname;
line = line.substr(1,13) + line.substr(14, accountname.size());
inFile << line;
cout << "Enter the desired password: "; cin >> password;
}
void loggingIn(){
system("CLS");
string line, line2, defaultaccount, defaultpassword, accountname;
fstream inFile;
inFile.open("exam.txt");
getline(inFile, line);
getline(inFile, line2);
defaultaccount = line.substr(14, line.size());
defaultpassword = line2.substr(10, line2.size());
cout << "Account: "; cin >> accountname;
if(accountname != defaultaccount)
cout << "That account name does not exist!\n" << endl;
else{
cout << "Password: "; cin >> accountname;
if(accountname != defaultpassword)
cout << "You entered an incorrect password!" << endl;
else
cout << "Your money: 5000\n" << endl;
}
}
int main(){
char c;
string line;
fstream inFile;
inFile.open("exam.txt");
if(inFile.fail()){
cerr << "Error Opening File" << endl;
exit(1);
}
cout << "-= Bank of Shithole =-\n\n";
while(c != 'E'){
getline(inFile, line);
do{
cout << "What do you want to do?\n(L) Login.\n(C) Create an account.\n(E) Exit.\n"; cin >> c;
if(islower(c))
c = toupper(c);
}while(c != 'L' && c != 'C' && c != 'E');
switch(c){
case 'L':
loggingIn();
break;
case 'C':
creatingAccount();
}
}
cout << "Come again!" << endl;
inFile.close();
}
|