Commit 05f45cf0 authored by sam.pople's avatar sam.pople

fss

parent 30341077
No preview for this file type
No preview for this file type
......@@ -3,13 +3,10 @@ public class BankAccount {
// Transactions are in pence
public BankAccount(int accountNumber, String name, int balance) {
this.Accountnumbervalue(accountNumber);
this.Namevalue(name);
this.Balancevalue(balance);
}
private int accountNumber;
private String name;
private int balance;
......@@ -51,40 +48,32 @@ public class BankAccount {
public String formatAmount(int amount) throws Exception {
String string;
boolean negative;
if (amount < 0) {
string = String.valueOf(amount * -1);
negative = true;
} else {
}
else {
string = String.valueOf(amount);
negative = false;
}
if (string.length() == 1) {
string = "00" + string;
}
if (string.length() == 2) {
}
if (negative) {
return "-£" + string.substring(0, string.length() - 2) + "." + string.substring(string.length() - 2, string.length());
} else {
}
else {
return "£" + string.substring(0, string.length() - 2) + "." + string.substring(string.length() - 2, string.length());
}
}
public void deposit(int amount) throws Exception {
this.Balancevalue(this.getBalance() + amount);
}
public boolean withdrawal(int amount) throws Exception {
if (this.getBalance() + this.getOverdraft() < amount) {
System.out.println("Not enough funds for a withdrawal \n");
System.out.println("Not enough funds for a withdrawal\n");
return false;
}
else {
......@@ -93,9 +82,8 @@ public class BankAccount {
return true;
}
}
public void bankFees() throws Exception {
this.Balancevalue(((int) Math.round(this.getBalance()*this.getFees())));
this.Balancevalue(((int) Math.round(this.getBalance() * this.getFees())));
}
public void display() throws Exception {
System.out.println("Bank details: \n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment