BO(Question 4.13.1:) Study, compile and run the following code:

@example
CLASS Car
BEGIN
PD COMM(/**)
PD COMM( * Car's model name)
PD COMM( */)
PD PROPERTY String model;

PD COMM(/**)
PD COMM( * Car's value in dollars)
PD COMM( */)
PD PROPERTY int value;

PD COMM(/**)
PD COMM( * Car's serial number)
PD COMM( */)
PD PROPERTY int serialNumber;

PD COMM(/**)
PD COMM( *   Global serial number counter)
PD COMM( */)
PD PRIVATE CLASSVAR int serialCounter = 1000;

PD CONSTRUCTOR Car(String aModel, int aValue)
PD BEGIN
PD PD model = aModel;
PD PD value = aValue;
PD PD serialNumber = serialCounter;
PD PD serialCounter = serialCounter + 1;
PD END

PD POBLIC METHOD String toString()
PD BEGIN
PD PD return "I am a car, model=" + model + ", value=" + value +
PD PD PD PD  ", serial number=" + serialNumber;
PD END
END

CLASS Owner
BEGIN

PD COMM(/**)
PD COMM( * Owner's full name)
PD COMM( */)
PD PROPERTY String name;

PD COMM(/**)
PD COMM( * Owner's money in dollars)
PD COMM( */)
PD PROPERTY int money;

PD COMM(/**)
PD COMM( * Owner's car)
PD COMM( */)
PD PROPERTY Car ownersCar;

PD CONSTRUCTOR Owner(String aName, int aMoney, Car aCar)
PD BEGIN
PD PD name = aName;
PD PD money = aMoney;
PD PD ownersCar = aCar;
PD END

PD POBLIC METHOD String toString()
PD BEGIN
PD PD return "I am a car owner, name=" + name + ", money=" + money +
PD PD PD PD  ", car=" + ownersCar;
PD END

PD POBLIC METHOD void describe()
PD BEGIN
PD PD System.out.println(toString());
PD END
END

CLASS CarTest
BEGIN
PD BEGINMAIN
PD PD VAR Car   ford = new Car("Ford Escort",1000);
PD PD VAR Car   nissan = new Car("Nissan Nivara",2000);
PD PD VAR Owner joe = new Owner("Joe Bloggs",500,ford);
PD PD) COMM(// Mary has no car to start with.)
PD PD VAR Owner mary = new Owner("Mary Smith",600,null);
PD PD joe.describe();
PD ENDMAIN
END
@end example

BO(Question 4.13.2:) What is the purpose of the CLASS variable serialCounter?

BO(Question 4.13.3:) Write a METHOD TT(sellCar) that increases the owner's
money by half the value of their car and the owner's car reference
gets set to NULL, for no car.  If the owner owns no car (NULL) simply
do nothing.

BO(Question 4.13.4:) Write a METHOD in the Owner CLASS called purchase so that:

@example
Car newCar = new Car("Mini Cooper",1000);
joe.purchase(newCar);
@end example

results in Joe's money going down by $1000 and Joe's car being set to
newCar.  Before Joe purchases their new car, call the TT(sellCar)
method so that Joe sells his current car before

BO(Question 4.13.5:)  Write a FUNCTION  in the Owner  class called
TT(netWorth) so that:

@example
System.out.println("Joe's net worth = " + joe.netWorth());
@end example

prints out Joes' money plus the value of his car, if he has a car.

BO(Question 4.13.6:) Write a method in the Owner CLASS called TT(smashCar)
so that:

@example
mary.smashCar();
@end example

NI()halves the value of Mary's car.

BO(Question 4.13.7:) Write a method in the Owner class called stealCarFrom so that:

@example
mary.stealCarFrom(joe);
@end example

results in Mary selling his current car (if he has one) for its market
value and Mary acquiring ownership of Joe's car. Also call Mary's
TT(sellCar) METHOD so that Mary sells her current car before stealing
Joe's car.

BO(Question 4.13.8:) Write a FUNCTION in the TT(Owner) CLASS called
TT(swapMoney) so that:

@example
Owner.swapMoney(joe,mary);
@end example

NI()swaps the money of Joe and Mary.

BO(Question 4.13.9:) Write a FUNCTION in the Owner class called swapCars so that:

@example
Owner.swapCars(joe,mary);
@end example

NI()swaps the cars of Joe and Mary.

BO(Question 4.13.10:) Write a FUNCTION in the Car class called
swapSerialNumbers so that:

@example
Car.swapSerialNumbers(ford,nissan);
@end example

NI()swaps the serial numbers of ford and nissan.

BO(Question 4.13.11:) Write a FUNCTION in the Owner class called
TT(sellCarTo) so that

@example
joe.sellCarTo(mary);
@end example

NI()results in Joe's money going up by the value of his car and Mary's
money going down by the value of his car, and the ownership of Mary's
car gets transferred to Joe.
