Skip to content

Commit

Permalink
Create WithdrawalSystem.java
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanxmiami committed Apr 9, 2021
1 parent 3a4e98a commit 1162bae
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions WithdrawalSystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import java.util.Locale;
import java.util.Scanner;

public class WithdrawalSystem extends MenuSelector{

BankAccount bankAccount = new BankAccount();
Scanner sc = new Scanner(System.in);

public boolean withdrawalSystem(){

if(bankAccount.getBalanceDenar() > 0.01)
System.out.println("Denar");
if(bankAccount.getBalancePound() > 0.01)
System.out.println("Pound");
if(bankAccount.getBalanceEuro() > 0.01)
System.out.println("Euro");
if(bankAccount.getBalanceDollar() > 0.01)
System.out.println("Dollar");
if(bankAccount.getBalanceYen() > 0.01)
System.out.println("Yen");
if(bankAccount.getBalanceDenar() + bankAccount.getBalancePound() + bankAccount.getBalanceEuro() + bankAccount.getBalanceDollar() + bankAccount.getBalanceYen() <= 0.01)
System.out.println("Your account is currently empty!");

while (withdrawCurrencyMenuActive) {
switch (sc.nextLine().toLowerCase(Locale.ROOT)) {
case "back":
case "b":
return false;

case "denar":
System.out.println("Enter Amount:\n");
double tempDen = sc.nextDouble();
if(tempDen > bankAccount.getBalanceDenar()) {
System.out.println(
"Insufficient funds in this currency!");
break;
}
else
bankAccount.withdrawBalanceDenar(tempDen);
return false;

/////////////////////////////////////////////////


case "pound":
System.out.println("Enter Amount:\n");
double tempPnd = sc.nextDouble();
if(tempPnd > bankAccount.getBalancePound()) {
System.out.println(
"Insufficient funds in this currency!");
}
else
bankAccount.withdrawBalancePound(tempPnd);
return false;

/////////////////////////////////////////////////

case "euro":
System.out.println("Enter Amount:\n");
double tempEur = sc.nextDouble();
if(tempEur > bankAccount.getBalanceEuro()) {
System.out.println(
"Insufficient funds in this currency!");
}
else
bankAccount.withdrawBalanceEuro(tempEur);
return false;

//////////////////////////////////////////////////

case "dollar":
System.out.println("Enter Amount:\n");
double tempDol = sc.nextDouble();
if(tempDol > bankAccount.getBalanceDollar()) {
System.out.println(
"Insufficient funds in this currency!");
}
else
bankAccount.withdrawBalanceDollar(tempDol);
return false;

////////////////////////////////////////////////////

case "yen":
System.out.println("Enter Amount:\n");
double tempYen = sc.nextDouble();
if(tempYen > bankAccount.getBalanceYen()) {
System.out.println(
"Insufficient funds in this currency!");
}
else
bankAccount.withdrawBalanceYen(tempYen);
return false;

default:
System.out.println("Please select a currency again!");
withdrawCurrencyMenuActive=true;
break;
}
withdrawCurrencyMenuActive=true;
}

return true;
}
}

0 comments on commit 1162bae

Please sign in to comment.