import java.util.ArrayList;
public class BankAccount {
private static double INT_RATE = 4.6;
private int accNo;
// Stores Client Name
private String accName;
// Stores balance of the account
private double balance;
// Store OverDraft Limit
private double clientodLimit;
// Store the date that teh account was opened
private String opened;
// Store a list of Clienttotaltransactions
private ArrayList Clienttotaltransactions;
private Date opened;
// DEFAULT CONSTRUCTOR
// Set attributes to default values that we specify
public BankAccount()
{
accNo = 0;
accName = "Empty";
balance = 0.0;
clientodLimit = 0;
opened = new Date();
Clienttotaltransactions = new ArrayList();
Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[4],0.0,0.0));
}
// COPY CONSTRUCTOR
public BankAccount(BankAccount a)
{
accNo = a.accNo;
accName = a.accName;
balance = a.balance;
clientodLimit = a.clientodLimit;
opened = new Date(a.opened);
Clienttotaltransactions = new ArrayList(a.Clienttotaltransactions);
}
public BankAccount(int no)
{
accNo = no;
accName = "Empty";
balance = 0.0;
clientodLimit = 0;
opened = new Date();
Clienttotaltransactions = new ArrayList();
Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[4],0.0,0.0));
}
public BankAccount(int no, String name, double bal)
{
accNo = no;
accName = name;
balance = bal;
clientodLimit = 0;
opened = new Date();
Clienttotaltransactions = new ArrayList();
Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[4],bal,bal));
}
// clone method
public Object clone()
{
BankAccount x = new BankAccount();
x.accNo = accNo;
x.accName = accName;
x.balance = balance;
x.clientodLimit = clientodLimit;
x.opened = new Date(opened);
x.Clienttotaltransactions = new ArrayList(Clienttotaltransactions);
return x;
}
// equals method
public boolean equals(Object other)
{
return accNo == ((BankAccount)other).accNo;
}
// toString() method - ALWAYS takes the form public String toString()
// Returns a string representation of the object
public String toString()
{
return accNo+": "+accName+": "+balance;
}
// RELEVANT ACCESSOR Methods
public void setAccName(String name)
{
accName = name;
}
public void setclientodLimit(double newLimit)
{
clientodLimit = newLimit;
}
public double getBalance()
{
return balance;
}
public String getAccName()
{
return accName;
}
public int getAccNo()
{
return accNo;
}
public static void ClientsetINT_RATE(double newIR)
{
INT_RATE = newIR;
}
public static double getINT_RATE()
{
return INT_RATE;
}
public void deposit(double amount)
{
balance = balance + amount;
Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[0],amount,balance));
}
public boolean withdraw(double widamount)
{
boolean valid = false;
if (checkWithdraw(widamount))
{
balance = balance - widamount;
valid = true;
Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[1],-widamount,balance));
}
return valid;
}
public void addInterestcalcu()
{
double interest = 0;
interest = balance*(INT_RATE/100);
deposit(interest);
}
private boolean checkWithdraw(double amount)
{
boolean valid = true;
if((balance-amount) < clientodLimit)
{
valid = false;
}
return valid;
}
public String createStatement()
{
// create a temporary string to hold the whole statement
String state = "";
// create a reference (pointer) to a Trans object
// called temp
Trans temp;
for(int i=0; i < Clienttotaltransactions.size(); i++)
{
temp = (Trans)Clienttotaltransactions.get(i);
state = state+"\n"+temp.toString();
}
return state;
}
}
I have some errors below, and I don't know how to fix them.
BankAccount.java:23: error: cannot find symbol private Date opened; ^ symbol: class Date location: class BankAccount BankAccount.java:33: error: cannot find symbol opened = new Date(); ^ symbol: class Date location: class BankAccount BankAccount.java:35: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[4],0.0,0.0)); ^ symbol: class Trans location: class BankAccount BankAccount.java:35: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[4],0.0,0.0)); ^ symbol: variable Trans location: class BankAccount BankAccount.java:45: error: cannot find symbol opened = new Date(a.opened); ^ symbol: class Date location: class BankAccount BankAccount.java:59: error: cannot find symbol opened = new Date(); ^ symbol: class Date location: class BankAccount BankAccount.java:61: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[4],0.0,0.0)); ^ symbol: class Trans location: class BankAccount BankAccount.java:61: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[4],0.0,0.0)); ^ symbol: variable Trans location: class BankAccount BankAccount.java:71: error: cannot find symbol opened = new Date(); ^ symbol: class Date location: class BankAccount BankAccount.java:73: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[4],bal,bal)); ^ symbol: class Trans location: class BankAccount BankAccount.java:73: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[4],bal,bal)); ^ symbol: variable Trans location: class BankAccount BankAccount.java:84: error: cannot find symbol x.opened = new Date(opened); ^ symbol: class Date location: class BankAccount BankAccount.java:141: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[0],amount,balance)); ^ symbol: class Trans location: class BankAccount BankAccount.java:141: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[0],amount,balance)); ^ symbol: variable Trans location: class BankAccount BankAccount.java:152: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[1],-widamount,balance)); ^ symbol: class Trans location: class BankAccount BankAccount.java:152: error: cannot find symbol Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE[1],-widamount,balance)); ^ symbol: variable Trans location: class BankAccount BankAccount.java:182: error: cannot find symbol Trans temp; ^ symbol: class Trans location: class BankAccount BankAccount.java:188: error: cannot find symbol temp = (Trans)Clienttotaltransactions.get(i); ^ symbol: class Trans location: class BankAccount Note: BankAccount.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 18 errors
So the error comes from opened, Date and Trans. I try to add some thing to valueable those words, but it doesn't work. : ( It need more detils, but I don't have more.