I have the following Account class which is the super class of CurrentAccount. I am however having issues when I create an instance of each class. The currentAccount should take away 6 as a charge if the balance is below 100 but its taking away 3. I'm obviously missing a deceleration somewhere.
public class Account {
private String name;
private double balance;
public double initDeposit;
public double threshold = 100.00;
public final double fee = 3.00;
public Account(String name, double initDeposit) {
this.balance = initDeposit;
this.name = name;
}
public void deposit(double amount) {
setBalance(amount);
}
public double getBalance() {
return balance;
}
public void setBalance(double amount) {
balance += amount;
}
public void withdraw(double amount) {
if (getBalance() < 100 && getBalance() >= -50) {
balance = balance - amount - fee;
} else {
balance = balance - amount;
}
}
public String toString() {
String s = "Name: " + name + "\n" + "Balance: " + balance;
return s;
}
}
public class CurrentAccount extends Account {
private String name;
private double balance;
public double initDeposit;
public double threshold = 100.00;
public final double fee = 6.00;
public CurrentAccount(String name, double initDeposit) {
super(name, initDeposit);
}
}
"taking away 6"and"taking away 3"?