The cloning approach taken here for Vehicle and PassengerVehicle is
the first "attitude" described in the text: support clone.  Calling
clone on a Vehicle is defined to return a new instance of the same
kind of Vehicle with the same properties, although with empty
"contents", if the particular type has a notion of contents like
passengers or cargo.  The Cloneable interface is implemented, and the
clone method throws no exceptions.  Thus, all subclasses of Vehicle
must also support cloning.  Certain vehicle subclasses may refer to
contents, and the types of such contents may not support cloning, but
this is not a problem because of the design choice that the original
Vehicle's contents are not present in a cloned version.
(Alternatively, the cloning of a Vehicle could have been specified to
mean cloning of its contents too, in which case the "conditionally
support clone" attitude would probably have to have been taken, or a
"shallow copy" would have to be performed.)

The simple copying done by Object.clone is not a sufficient clone
implementation for Vehicle because all instances of Vehicle must have
a unique value for their VIN field, so a new VIN must be explicitly
assigned in the cloned version.  It is also insufficient for
PassengerVehicle because the seatsOccupied field must be set to zero
(and if PassengerVehicle had references to its passengers, these would
have to be cleared too).


class Vehicle implements Cloneable {
    private long VIN;
    private String ownerName = "<unknown owner>";
    private float speed = 0;
    private float direction = 0;

    private static long nextVIN = 0;

    public Vehicle() {
	VIN = nextVIN++;
    }

    public Vehicle(String name) {
	this();
	ownerName = name;
    }

    public Object clone() {
	try {
	    Vehicle nObj = (Vehicle)super.clone();
	    nObj.VIN = nextVIN++;
	    return nObj;
	} catch (CloneNotSupportedException e) {
	    // can't happen
	    throw new InternalError(e.toString());
	}
    }

    // rest of Vehicle class from before...
}


class PassengerVehicle extends Vehicle {

    private int seats;
    private int seatsOccupied;

    public PassengerVehicle(String name, int seatsAvail) {
	super(name);
	seats = seatsAvail;
    }

    public PassengerVehicle(int seatsAvail) {
	super();
	seats = seatsAvail;
    }

    public Object clone() {
	PassengerVehicle nObj = (PassengerVehicle)super.clone();
	nObj.seatsOccupied = 0;
	return nObj;
    }

    // rest of PassengerVehicle class from before...
}
