nie-ii-year

lab stuff from undergrad second year.
git clone http://git.hanabi.in/repos/nie-ii-year.git
Log | Files | Refs | LICENSE

commit fd36763205c27e0ecb651f2aade914ffb4dc4a68
parent ed4911aaa8feeb6545ff968ce6c7f8203415fb9b
Author: Agastya Chandrakant <acagastya@outlook.com>
Date:   Fri,  8 Sep 2017 04:54:26 +0530

need breaks
Diffstat:
Ms3/oops/bank.cpp | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/s3/oops/bank.cpp b/s3/oops/bank.cpp @@ -19,6 +19,7 @@ void BBVA::assign(int x) { cout << "Enter the name, account type and balance for account number " << x << " :\t"; cin >> name >> accountType >> balance; accountNumber = x; + fflush(stdin); } void BBVA::deposit(float x) { @@ -59,6 +60,7 @@ int main() { cout << "\nInsufficient memory.\n"; return 0; } + BBVA *b = a; do{ sum = 0; cout << "\nEnter number corrosponding to their label\n1. Enter the details\t2. Deposit money\n3. Withdraw money\t4. Display details\n5. Add more accounts\t6. Exit\n\nYour input> "; @@ -77,8 +79,10 @@ int main() { case 2: cout << "\nEnter the account number. (Between 0 and " << max - 1 << ")\nYour input> "; cin >> index; - if(index < 0 || index >= max) + if(index < 0 || index >= max) { cout << "\nAccount not found. Can not deposit money.\n"; + break; + } cout << "Enter amount to be deposited.\nYour input> "; cin >> sum; a[index].deposit(sum); @@ -86,8 +90,10 @@ int main() { case 3: cout << "\nEnter the account number. (Between 0 and " << max - 1 << ")\nYour input> "; cin >> index; - if(index < 0 || index >= max) + if(index < 0 || index >= max) { cout << "\nAccount not found. Can not withdraw money.\n"; + break; + } cout << "Enter amount to be withdrawn.\nYour input> "; cin >> sum; a[index].withdraw(sum); @@ -95,8 +101,10 @@ int main() { case 4: cout << "\nEnter the account number. (Between 0 and " << max - 1 << ")\nYour input> "; cin >> index; - if(index < 0 || index >= max) + if(index < 0 || index >= max){ cout << "\nAccount not found. Can not display details.\n"; + break; + } a[index].display(index); break; case 5: @@ -104,6 +112,10 @@ int main() { cin >> maxNew; if(maxNew > max) { a = (BBVA *) realloc(a, maxNew * sizeof(BBVA)); + if(a == NULL) { + cout << "Insufficient memory.\n"; + a = b; + } max = maxNew; cout << "\nNumber of accounts has been updated to " << max << ".\n"; }