Specification: Realize a Java class for representing cars. The properties of interest for a car are the plate number, the model, the color, and the person who owns the car. The first two properties cannot be modified, while the third and fourth can. A car has initially no owner. The owner is assigned to a car only later (e.g., when the car is sold).
By analyzing the above specification, we see that we have to realize a class Car, whose functionalities are:
At this point we are ready to write:
public class Car { // private representation of the objects: instance variables // public methods realizing the requested functionalities }