Skip to content

Commit

Permalink
Merge pull request #47 from fkamau1/withdraw-function
Browse files Browse the repository at this point in the history
Add withdraw function
  • Loading branch information
fkamau1 authored Jan 21, 2024
2 parents fb5325e + a697373 commit a5fb8ed
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 33 deletions.
8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/modules/bankingApp.iml

This file was deleted.

Binary file modified account.db
Binary file not shown.
Binary file modified app/account.db
Binary file not shown.
21 changes: 16 additions & 5 deletions app/src/main/java/bankingapp/LogIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ public void checkAccount(DBTransactions db, Connection con, String accountNumber
do {
System.out.println("\n1. Balance\n" +
"2. Add income\n" +
"3. Do transfer\n" +
"4. Close Account\n" +
"5. Log Out\n" +
"3. Withdraw\n" +
"4. Do transfer\n" +
"5. Close Account\n" +
"6. Log Out\n" +
"0. Exit");

answer = input.nextInt();
Expand All @@ -57,10 +58,18 @@ public void checkAccount(DBTransactions db, Connection con, String accountNumber
break;

case 3:
App.transferFunds(db, con, accountNumber);
System.out.println("Enter amount to withdraw:");
int withdraw = input.nextInt();
db.deductBalance(withdraw, accountNumber);
System.out.println("Amount withdrawn: " + withdraw);
System.out.println("New balance: " + db.checkBalance(accountNumber));
break;

case 4:
App.transferFunds(db, con, accountNumber);
break;

case 5:
if (db.checkBalance(accountNumber) > 0) {
System.out.println("Transfer account balance to a different account before closing");
} else {
Expand All @@ -70,12 +79,14 @@ public void checkAccount(DBTransactions db, Connection con, String accountNumber
}
break;

case 5:
case 6:
System.out.println("\nYou have successfully logged out");
break subMenu;

case 0:
System.out.println("Bye");
System.exit(0);

}
} while (answer != 0);

Expand Down

0 comments on commit a5fb8ed

Please sign in to comment.