below is my complete code for a bank account class and the measurable interface and my InsufficientFundsException class. My bankAccount class doesnt' recognize the interface or the exception class I designed. I keep getting the error below. The interface and the InsufficientFundsException class compiles with no problem.
C:\Documents and Settings\felipewalker\Desktop\BankAccount\BankAccount.java:5: cannot resolve symbol
symbol : class Measurable
location: class BankAccount
public class BankAccount implements Measurable{
^
C:\Documents and Settings\felipewalker\Desktop\BankAccount\BankAccount.java:49: cannot resolve symbol
symbol : class InsufficientFundsException
location: class BankAccount
throw new InsufficientFundsException("withdrawal of " + amount + " exceeds balance of " + balance);
^
2 errors
Tool completed with exit code 1
the Code
------------------
public interface Measurable {
double getMeasure();
}
public class InsufficientFundsException extends RuntimeException{
public InsufficientFundsException(){}
public InsufficientFundsException(
String reason){
super(reason);
}
}
import javax.swing.JOptionPane;
/**
A bank account has a balance that can be changed by deposits and withdrawals.
*/
public class BankAccount implements Measurable{
/**
Constructs a bank account with a zero balance.
*/
public BankAccount(){
balance = 0;
}
/**
Constructs a bank account with a given balance.
@param initialBalance the initial balance
*/
public BankAccount(double initialBalance){
if(initialBalance >= 0){
balance = initialBalance;
}
else
JOptionPane.showMessageDialog(null,"Invalid Amount","Initial Balance can not be less than $0.00",JOptionPane.WARNING_MESSAGE);
}
/**
Deposits money into a bank account.
@param amount the amount to deposit
*/
public void deposit(double amount){
if (amount >= 0){
double newBalance = balance + amount;
balance = newBalance;
}
else
JOptionPane.showMessageDialog(null,"Invalid Amount","Deposit can not be less than $0.00",JOptionPane.WARNING_MESSAGE);
}
/**
Withdraws money from a bank account.
@param amount the amount to withdraw
*/
public void withdraw(double amount){
if (amount <= balance){
double newBalance = balance - amount;
balance = newBalance;
}
else {
balance = balance - OVERDRAFT_PENALTY;
throw new InsufficientFundsException("withdrawal of " + amount + " exceeds balance of " + balance);
}
}
/**
Gets the current balance of the bank account.
@return the curent balance
*/
public double getBalance(){
return balance;
}
/**
Adds intrest to the balance.
@param rate the current intrest rate
*/
public void transfer(BankAccount other, double amount){
withdraw(amount);
other.deposit(amount);
}
public double getMeasure(){
return balance;
}
private double balance;
final double OVERDRAFT_PENALTY = 35.00;
}
