Commit e941d94b authored by sam.pople's avatar sam.pople

new final submission

parent 538f5eea
No preview for this file type
No preview for this file type
...@@ -2,22 +2,22 @@ public class BankAccount { ...@@ -2,22 +2,22 @@ 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;
private double fees = 0.95; private double fees = 0.95;
protected int overdraft = 0; protected int overdraft = 0;
public int getAccountNumber() { public int getAccountNumber() {
return accountnumber; return accountNumber;
} }
public String getName() { public String getName() {
return name; return name;
...@@ -32,8 +32,8 @@ public class BankAccount { ...@@ -32,8 +32,8 @@ public class BankAccount {
return overdraft; return overdraft;
} }
public void Accountnumbervalue(int accountnumber) { public void Accountnumbervalue(int accountNumber) {
this.accountnumber = accountnumber; this.accountNumber = accountNumber;
} }
public void Namevalue(String name) { public void Namevalue(String name) {
this.name = name; this.name = name;
...@@ -86,7 +86,6 @@ public class BankAccount { ...@@ -86,7 +86,6 @@ public class BankAccount {
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 {
this.Balancevalue(this.getBalance() - amount); this.Balancevalue(this.getBalance() - amount);
System.out.println("Withdrawal successful " + this.formatAmount(amount) + "\n"); System.out.println("Withdrawal successful " + this.formatAmount(amount) + "\n");
...@@ -95,18 +94,12 @@ public class BankAccount { ...@@ -95,18 +94,12 @@ public class BankAccount {
} }
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");
System.out.println("Account no.: " + this.getAccountNumber() + "\nAccount holder: "+this.getName()); System.out.println("Account no.: " + this.getAccountNumber() + "\nAccount holder: "+this.getName());
String balance = this.formatAmount(this.getBalance()); String balance = this.formatAmount(this.getBalance());
System.out.println("Balance: " + balance); System.out.println("Balance: " + balance);
} }
} }
public class SavingsAccount extends BankAccount { public class SavingsAccount extends BankAccount {
public SavingsAccount(int accountnumber, String name, int balance) { public SavingsAccount(int accountNumber, String name, int balance) {
super(accountnumber, name, balance); super(accountNumber, name, balance);
this.Feesvalue(1.00); this.Feesvalue(1.00);
} }
......
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