Question: In Java Write an equals method for the Car class given here. Two Cars are equal if their Vehicle Identification Numbers (VIN) are the same.

In Java

Write an equals method for the Car class given here. Two Cars are equal if their Vehicle Identification Numbers (VIN) are the same. HINT: The String class has an equals method that can be called from the Car class equalsmethod.

In Java Write an equals method for the Car class given here.

UML diagrams

Draw the UML diagram for the Car class from Exercise 2 after including the equals method.

Pt.2

Arrays of Objects

  1. Declare and instantiate an array of 40 cars using the Car class. Name the array dealerCars.
  2. Write Java statements to add three cars to the dealerCars array.
  3. Make a hole at the beginning of the dealerCars array by moving the cars in the array up by one position.
  4. Add another car to the beginning of the array.
  5. Write a for loop to display all the cars in the dealerCars array. Add any necessary methods to the Car class.

public class Car { private String vin; private String color; public Car() { vin = ""; } public Car(String vin, String color) { this.vin = vin; this.color = color; } }

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!