-2

Forgive me as I am still a newb to Java.I have 9 different classes. In my account driver i need to create a method load data, where I can put in some fake data.

I cant seem to figure out how to enter the values for these as my constructors are:

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;


}

and my 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());
}

}

SikRik
  • 5
  • 1
  • 5
  • What would you like to do? put all instances of those classes in the same `ArrayList`? or put them in different `ArrayList`s? – Assaf Sep 11 '14 at 16:58

3 Answers3

0

You need to create all the necessary instances:

Customer c = new Customer("John", "Doe");
Day day = new Day(2014, 9, 11);
Account account = new Account(c, 1000D, day);
// add the account
List<Account> accounts = new ArrayList<>();
accounts.add(account);
Jean Logeart
  • 52,687
  • 11
  • 83
  • 118
0
Account account = 
    new Account( new Customer("first name","last name"), 10.0d, new Day(2014,9,11));
Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
StackFlowed
  • 6,664
  • 1
  • 29
  • 45
0

You must pass in parameters that match the constructor method signature. Here is an example:

Customer customer = new Customer("Doe","John");
double balance = 1000.0;
Day day = new Day(1992,4,20);

a.add(new Account(customer, balance, day));
forgivenson
  • 4,394
  • 2
  • 19
  • 28