2016-04-27 99 views
-1
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: 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

所以這個錯誤來自於打開的Date和Trans。我試圖添加一些東西來評估這些詞,但它不起作用。 :( 它需要更多的detils,但我沒有更多

+0

什麼和在哪裏是類反式? – Blip

回答

1

您需要導入正確的包爲Date

java.util.Date 

做了跨類和顯示所有其他人一樣同樣的錯誤原因....

+0

其餘的是什麼? – Savior

+0

是不夠直觀,以解決類似的問題???? –

+0

你問我或OP?像這樣,我認爲你需要更多地進食。 – Savior

相關問題