请原谅我,因为我仍然是 Java 的新手。我有 9 个不同的课程。在我的帐户驱动程序中,我需要创建一个方法加载数据,我可以在其中放入一些假数据。
我似乎无法弄清楚如何输入这些值,因为我的构造函数是:
public Account(Customer c,double b,Day d){
cust = c;
balance= b;
dateOpened=d;
}
public Customer(String last, String first)
{
this.last = last;
this.first=first;
custNum = nextNum;
nextNum++;
}
public Day(int yyyy, int m, int d)
{ year = yyyy;
month = m;
day = d;
if (!isValid())
throw new IllegalArgumentException();
}
public CheckingAccount(double mf,Customer c,double b,Day d){
monthlyFee=mf;
}
public SavingsAccount(Customer c,double b,Day d,double i){
intRate=i;
}
public SuperSavings(double mf,Customer c,double b,Day d,double m){
minDeposit=m;
}
和我的 AccountDriver:
import java.util.ArrayList;
public class AccountDriver {
public static void main(String[] args){
ArrayList<Customer> c = new ArrayList<Customer>();
ArrayList<Account> a = new ArrayList<Account>();
ArrayList<Day> d = new ArrayList<Day>();
loadData(c,a,d);
print(a);
}
public static void loadData(ArrayList<Customer> c,ArrayList<Account> a, ArrayList<Day> d) {
a.add(new Account(new Customer("Sam", "Jones"),45000,new Day(2012,12,4)));
}
private static void print(ArrayList<Account> s) {
for (int i=0;i<s.size();i++)
System.out.println(s.get(i).toString());
}
}