Question: 4.1 a. Write a class Car that has the following attributes: - make: String, the car make (e.g. Oldsmobile) model: String, the model name (e.g.

4.1 a. Write a class Car that has the following attributes: - make: String, the car make (e.g. Oldsmobile) model: String, the model name (e.g. "442") - built date: java.util.Date, the official manufacture date The Car class provides a constructor Car(String make, String model, Date whenBuilt) that initializes the corresponding fields. The Car class should have accessors for make, model, and the built date and a useful implementation of the toString() method Make sure the class is immutable. Be *careful* with that Date field -- remember what to do when sharing mutable instance variables -- issues discussed in Chapter 3 for a class called Employee. Write contracts for all methods: preconditions/postconditions Write the class invariant in the class javadoc comment. Some preconditions are trivial. Just say 'none b. Implement a static method in class Student public static Comparator
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
