如何修复无法在此找到符号

时间:2016-04-27 18:40:37

标签: java

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;
    }

}   

我在下面有一些错误,我不知道如何修复它们。

  

BankAccount.java:23:错误:找不到符号          私人日期开放;                  ^         符号:类日期         location:班级BankAccount       BankAccount.java:33:错误:找不到符号             opens = new Date();                          ^         符号:类日期         location:班级BankAccount       BankAccount.java:35:错误:找不到符号             Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [4],0.0,0.0));                                             ^         符号:类Trans         location:班级BankAccount       BankAccount.java:35:错误:找不到符号             Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [4],0.0,0.0));                                                   ^         符号:变量Trans         location:班级BankAccount       BankAccount.java:45:错误:找不到符号             open = new Date(a.opened);                          ^         符号:类日期         location:班级BankAccount       BankAccount.java:59:错误:找不到符号             opens = new Date();                          ^         符号:类日期         location:班级BankAccount       BankAccount.java:61:错误:找不到符号             Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [4],0.0,0.0));                                             ^         符号:类Trans         location:班级BankAccount       BankAccount.java:61:错误:找不到符号             Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [4],0.0,0.0));                                                   ^         符号:变量Trans         location:班级BankAccount       BankAccount.java:71:错误:找不到符号             opens = new Date();                          ^         符号:类日期         location:班级BankAccount       BankAccount.java:73:错误:找不到符号             Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [4],bal,bal));                                             ^         符号:类Trans         location:班级BankAccount       BankAccount.java:73:错误:找不到符号             Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [4],bal,bal));                                                   ^         符号:变量Trans         location:班级BankAccount       BankAccount.java:84:错误:找不到符号             x.opened =新日期(已开放);                            ^         符号:类日期         location:班级BankAccount       BankAccount.java:141:错误:找不到符号             Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [0],amount,balance));                                             ^         符号:类Trans         location:班级BankAccount       BankAccount.java:141:错误:找不到符号             Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [0],amount,balance));                                                   ^         符号:变量Trans         location:班级BankAccount       BankAccount.java:152:错误:找不到符号                 Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [1], - widamount,balance));                                                 ^         符号:类Trans         location:班级BankAccount       BankAccount.java:152:错误:找不到符号                 Clienttotaltransactions.add(new Trans(Trans.TRANSTYPE [1], - widamount,balance));                                                       ^         符号:变量Trans         location:班级BankAccount       BankAccount.java:182:错误:找不到符号             Trans temp;             ^         符号:类Trans         location:班级BankAccount       BankAccount.java:188:错误:找不到符号                 temp =(Trans)Clienttotaltransactions.get(i);                         ^         符号:类Trans         location:班级BankAccount       注意:BankAccount.java使用未经检查或不安全的操作。       注意:使用-Xlint重新编译:取消选中以获取详细信息。       18个错误

因此错误来自open,Date和Trans。我试着添加一些东西给那些有价值的东西,但它不起作用。 :( 它需要更多的detils,但我没有更多。

1 个答案:

答案 0 :(得分:1)

您需要导入Date

的正确包
java.util.Date

对Trans类和显示相同错误的所有其他内容执行相同的操作....