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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include "accountData.h" // not related --
void main_Menu();
bool login_validation(string usrName, string pin);
void login_page();
void forgot_password();
void clearScreen();
void account_Page();
int main()
{
clearScreen();
main_Menu(); // call main_menu();
return 0;
}
void main_Menu()
{
int choice;
cout << "-------------------------------------------------------------" << endl;
cout << " WELCOME TO " << endl;
cout << " BANK " << endl;
cout << "-------------------------------------------------------------" << endl;
cout << "1.\t LOGIN" << endl;
cout << "2.\t FORGOT PASSWORD" << endl;
cout << "Enter your choice (1-2)" << endl;
cin >> choice;
while (choice <0 || choice >3) // Validate input
{
cout << "INVALID INPUT, PLEASE ENTER 1 OR 2 ONLY\n";
cin >> choice;
}
switch (choice) {
case 1: login_page(); // if user input '1' then call function login_page
break;
case 2: forgot_password(); // if user input '2' then call function forgot_password
break;
}
void ClearScreen();
}
void login_page()
{
string username, password;
clearScreen(); // call clear screen
bool validateLogin; // set initial value of validateLogin as false
// declare string variables as input for argument login_Validatio
do{ // do while syntax .. .
cout << "Enter Username : \n"; // prompt user to input username
getline(cin,username); // store nameLogin string
cin.ignore();
cout << "Enter Password : \n"; // prompt user to input username
getline(cin,password); // store passLogin string
cin.ignore();
validateLogin = login_validation(username,password);
if(validateLogin) // if validateLogin accept true value then proceed
{
clearScreen(); // clear screen
account_Page(); // go to account_Page function
}
else
cout << "INVALID INPUT. ENTER CORRECT USERNAME/PASSWORD!.\n"; //display if login input is false
}while(!validateLogin); // keep repeating loop while login input isn't correctly entered.
}
void forgot_password()
{
bool goOn=false; // initial value set to false
int choice; // variable to store user's choice
clearScreen(); // call clearScreen function
const int MIN_VALUE = 1000000; // set min value of random-number generated
const int MAX_VALUE = 9999999; // max value of random-numer generated
int ticketNumber; // declare ticket_Number variable
unsigned seed = (unsigned int) time(0); // seed generated by time
srand(seed);
ticketNumber = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE; // formula to generate random-number
cout << "--------------------------------------------\n"; // display
cout << " WE'VE MADE YOU A TICKET \n"; // display
cout << "\t Ticket Number : " << ticketNumber << endl; // display
cout << "PLEASE KEEP THIS TICKET NUMBER TO CONTACT US.\n"; // display
cout << "--------------------------------------------\n"; // display
do { // do start
cout << "Enter 1 to Main Menu" << endl; // display choice 1
cout << "Enter 2 to Exit" << endl; // display choice 2
cin >> choice; // prompt user to enter choice;
switch (choice){ // switch statement start
case 1 : { // case 1
goOn = true; //
clearScreen(); // clear screen func
main_Menu(); // go to main_Menu()
break; // break statement if case 1 fulfill
}
case 2 :{ // case 2
cout << "Exit Now."; // display exit
break; // break statement ifcase 2 fulfill
}
default : { // default switch
cout <<"INVALID INPUT. ENTER 1 OR 2 ONLY!."; // display
break; // break
}
}
}while (goOn);
}
bool login_validation(string usrName, string pass) {
bool valid = false;
string getUsrname, getPass, getID;
ifstream data;
data.open("dataLogin.txt");
while (data >> getUsrname >> getPass >> getID) {
if (usrName == getUsrname && pass == getPass) {
valid = true;
break;
}
}
if(valid){
return true;
}
else{
return false;
}
data.close();
}
void clearScreen() //function to clear the screen
{
cout << string( 100, '\n' );
}
void account_Page(){ // start func account_Page()
//AccountData logindata;
int choice;
ifstream userAccount;
if(userAccount.good()){
userAccount.open("filename.txt"); //ignore it (updte)
}
else {
cout << "SOME FILES ARE MISSING. PLEASE CONTACT ADMINISTRATOR!.\n";
}
clearScreen();
string usrName, usrBalance;
getline(userAccount, usrName, '|');
cout << "---------------------------------------------------\n";
cout << "Hi, " << usrName << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << "---------------------------------------------------\n";
cout << "1. CHECK BALANCE \n";
cout << "2. FUNDS TRANSFER \n";
cout << "3. SELECT PAYMENTS \n";
cout << "4. ACCOUNT SETTINGS \n";
cout << "5. LOG OUT\n";
cout << "6. CANCEL \n";
cout << "Enter your choice: \n";
cin >> choice;
userAccount.close();
} // end func account_Page()
void check_Balance(){
clearScreen();
ifstream accountDetails; // get balanceData from text file..
cout << "Your Balance is : \n";
}
int cancel_Select(){
cout << "Exit Now...";
return 0;
}
|