ClassNotFoundException(Throwable)。<init>(String,Throwable)行:286

时间:2016-07-13 18:27:22

标签: java arraylist

我正在开展一个学校项目,我正在使用继承和数组列表。 Checking和Saving类都继承自Account类。还有一个额外的Transaction类,用于为Checking List和Saving类中的Array List构建一个对象。该项目要求以期初余额开立账户。完成后,需要能够从这些账户中提取和存入资金。这是阵列列表发挥作用的地方。一种是进行撤销/存款,从Transaction类中创建一个对象,然后将其添加到数组列表中。

这似乎是我的问题所在。似乎我无法在Savings类中的withdraw方法中创建一个对象。当我打印出我的数组列表中的内容时,我得到以下输出。

  

question8.TestClassAccount.Transaction@1bf8de1

以下是我的代码。

import java.util.Scanner;



public class TestAccount {

public static void main(String[] args){

        int idNum = 0;
        double limit = 0, openBalSav = 0;
        String customer = "";

        Scanner input = new Scanner(System.in);

        System.out.println("What is the customer's' name? ");
        customer = input.nextLine();
        System.out.println("What is the Account ID? ");
        idNum = input.nextInt();        
        System.out.println("How much are we putting in Savings? ");
        openBalSav = input.nextDouble();
        System.out.println("What is the overdraft limit? ");
        limit = input.nextDouble();
        input.nextLine();
        Account accSav = new Savings(idNum, openBalSav, customer, limit);
        accSav.withdraw(100.00);
        accSav.withdraw(50.00);
        accSav.withdraw(75.00);
        accSav.printTransactions();

}

public class Savings extends Account {

private double overdraftLimit;
private double amount;
private char type;
private int year;
private int month;
private int day;
private String description;
private ArrayList<Transaction> list = new ArrayList<Transaction>();

public Savings(){
    super();
    this.overdraftLimit = 0;
}
//Opening Account Constructor;
public Savings(int id, double balance, String customer,double             `enter code here`overdraftLimit){
    super(id, balance, customer);
    this.overdraftLimit = overdraftLimit;
}

public double withdraw(double amount){
    double newBalance = getBalance();
    newBalance -= amount;
    setBalance(newBalance); 
    Transaction item = new Transaction('w', amount, "withdraw");//break here
    list.add(item);
    return amount;
    }
}

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Transaction {

private Calendar dateCreated = Calendar.getInstance();
private char type;
private double amount;
private double balance;
private String description;
private DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
int year;
int month;
int day;
public Transaction(){
    this.type = 'w';
    this.amount = 0.00;
    this.balance = 0.00;
    this.description = "No description yet";
    this.dateCreated.getTime();
}

public Transaction(char type, double amount, String description){
    this.type = type;
    this.amount = amount;
    this.description = description;
    }

}

0 个答案:

没有答案