phils exercise

Exercise 1
A class called Vehicle is required by a programmer who is
writing software for a car dealer. An object of the class Vehicle
will consist of a registration number, the make of the vehicle,
the year of manufacture and the current value of the vehicle.
The first three of these will need to be set only at the time the
object is created. The current value will also be set at the time
of creation, but may need to be changed during the vehicle’s

Write the code for the Vehicle class.

A subclass of Vehicle called SecondHandVehicle is required.
The subclass will have an additional attribute, numberofOwners.

Write a tester class that tests all the methods of the SecondHand
Vehicle class.

Exercise 2
Write a bank account class that allows you to:
• Open an account with an initial balance (the
• Deposit money
• Withdraw money
• Retrieve the balance of the account

Write a class called InterestBearingAccount that inherits
from the account class and
that allows you to:
• Open an account of this type (the constructor)
• Add monthly interest to your balance

Write a test class to open an interest account, deposit
money, withdraw and add interest to the balance.