Page 509 - Introduction to Programming with Java: A Problem Solving Approach
P. 509
12.2 Composition and Aggregation 475
/************************************************************
*
Dealership.java
Dean & Dean
This represents an auto retail sales organization.
************************************************************/
*
*
*
import java.util.ArrayList;
public class Dealership
{
}
// end Dealership class
private String company;
private Manager manager;
private ArrayList<SalesPerson> people = ⎫ new ArrayList<SalesPerson>(); ⎬⎪ private ArrayList<Car> cars = new ArrayList<Car>(); ⎭
//*********************************************************
public Dealership(String company, Manager manager)
this.company = company;
this.manager = manager;
Apago PDF Enhancer
{
}
//*********************************************************
public void addCar(Car car)
{
}
}
{
}
System.out.println(company + "\t" + manager.getName());
for (SalesPerson person : people)
System.out.println(person.getName());
for (Car car : cars)
System.out.println(car.getMake());
// end printStatus
cars.add(car);
public void addPerson(SalesPerson person)
{
people.add(person);
//*********************************************************
public void printStatus()
Containership implemented here.
Figure 12.3
Dealership class for Dealership program