class FleetTester
{
public static void main ( String[] args)
{
Fleet myCars = new Fleet( 1000, 1234, 10, 777, 999, 20 );
}
}
Die Autos, aus denen eine Flotte besteht, werden konstruiert, wenn die Flotte konstruiert wird. Hier ist das Programm mit etwas Zusatzarbeit:
class Fleet
{
// Daten
Car town;
Car suv;
// Konstruktor
Fleet( int start1, int end1, double gal1,
int start2, int end2, double gal2 )
{
town = ________________________ ;
suv = ________________________ ;
}
// Methode
}
class Car
{
. . . .
Car( int first, int last, double gals )
{
. . . .
}
}
class FleetTester
{
public static void main ( String[] args)
{
Fleet myCars = new Fleet( 1000, 1234, 10, 777, 999, 20 );
}
}