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 { ...@@ -3,13 +3,10 @@ public class BankAccount {
// Transactions are in pence // Transactions are in pence
public BankAccount(int accountNumber, String name, int balance) { public BankAccount(int accountNumber, String name, int balance) {
this.Accountnumbervalue(accountNumber); this.Accountnumbervalue(accountNumber);
this.Namevalue(name); this.Namevalue(name);
this.Balancevalue(balance); this.Balancevalue(balance);
} }
private int accountNumber; private int accountNumber;
private String name; private String name;
private int balance; private int balance;
...@@ -51,40 +48,32 @@ public class BankAccount { ...@@ -51,40 +48,32 @@ public class BankAccount {
public String formatAmount(int amount) throws Exception { public String formatAmount(int amount) throws Exception {
String string; String string;
boolean negative; boolean negative;
if (amount < 0) { if (amount < 0) {
string = String.valueOf(amount * -1); string = String.valueOf(amount * -1);
negative = true; negative = true;
}
} else { else {
string = String.valueOf(amount); string = String.valueOf(amount);
negative = false; negative = false;
} }
if (string.length() == 1) { if (string.length() == 1) {
string = "00" + string; string = "00" + string;
} }
if (string.length() == 2) { if (string.length() == 2) {
} }
if (negative) { if (negative) {
return "-£" + string.substring(0, string.length() - 2) + "." + string.substring(string.length() - 2, string.length()); 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()); return "£" + string.substring(0, string.length() - 2) + "." + string.substring(string.length() - 2, string.length());
} }
} }
public void deposit(int amount) throws Exception { public void deposit(int amount) throws Exception {
this.Balancevalue(this.getBalance() + amount); this.Balancevalue(this.getBalance() + amount);
} }
public boolean withdrawal(int amount) throws Exception { public boolean withdrawal(int amount) throws Exception {
if (this.getBalance() + this.getOverdraft() < amount) { 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; return false;
} }
else { else {
...@@ -93,9 +82,8 @@ public class BankAccount { ...@@ -93,9 +82,8 @@ public class BankAccount {
return true; return true;
} }
} }
public void bankFees() throws Exception { 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 { public void display() throws Exception {
System.out.println("Bank details: \n"); 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