Question: Question 1 (20 points] Implement the class Car only. The code of the classes Vehicle and Truck is provided below. Vehicle -brand: String -year: int

 Question 1 (20 points] Implement the class Car only. The code

Question 1 (20 points] Implement the class Car only. The code of the classes Vehicle and Truck is provided below. Vehicle -brand: String -year: int +Vehicle(---All Parameters--- +toString(): String Car -noPassengers: int +Car(--- All Parameters---) +describeSize(): void +equals(o: Object): boolean +toString(): String Truck -loadCapacity: double +Truck (--- All Parameters---) +getLoadCapacity(): double +toString(): String public class Vehicle { private String brand; private int year; public Vehicle (String brand, int year) { this.brand = brand; this.year = year; } public String toString() { return "Vehicle" + "brand=" + brand + ", year=" + year + '/'; 1 public class Truck extends Vehicle private double loadCapacity; public Truck (double loadCapacity, String brand, int year) { super (brand, year); this.loadCapacity loadCapacity; 1 public double getLoadCapacity () { return loadCapacity: } public String toString() { return "Truck/" + "loadCapacity=" + loadCapacity = ''; 1 } Page 4 of 5 CSC1300 Final Makeup Exam Fall 2020 - 2021 Implement the class Car by writing the following methods: a) The constructor takes all parameters. [5 pts] b) The method describeSize displays Small if the number of passengers is four or less, Medium if the number of passengers is five and "Large" otherwise. [5 pts] c) The method equals which overrides the equals method of the Object class is used to check if two Car objects are equal based on the number of passengers. [5 pts] d) The toString method returns the description of the Object including all attributes. [5 pts] Question 2 [20 points) Write a client class (application) in which you: a) Create an array of type Vehicle of size 10 and fill it from the user with either cars or trucks according to the user's choice. Then copy all Vehicle objects from the array to an arraylist of type Vehicle. [5 pts] b) Display all Truck objects in the arrayList with loadCapacity larger than 10,000 kilos. [5 pts) c) Copy the Car objects and the Vehicle Objects to two different ArrayList objects of types Car and Truck respectively. [5 pts] d) Check if the first Car object and the last Car object in the arrayList of Cars are equal or not and display the appropriate message. [5 pts]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!