01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
package myproject.model;

import java.util.List;
import java.util.ArrayList;

/**
 * A road holds cars.
 */
public class Road {
  Road() { } // Created only by this package

  private List<Car> cars = new ArrayList<Car>();

  public void accept(Car d) {
    if (d == null) { throw new IllegalArgumentException(); }
    cars.add(d);
  }
  public List<Car> getCars() {
    return cars;
  }
}