All vehicles used for transportation in the U.S. must have identification, which varies according to the type of vehicle. For example, all automobiles have a unique Vehicle Identification Number (VIN) assigned by the manufacturer, plus a license plate number assigend by the state in which the auto is registerd. Your task is to modify the Auto class below to override the equals method of the Vehicle class to test that the VIN and license plate number are identical.

Complete the following file:

Auto.java

/** Represents an automobile. */ public class Auto extends Vehicle { private String licensePlate; public Auto(String vin, String plate) { super(vin); licensePlate = plate; } // TODO: Override the equals method of the Object class to // test that VIN and license plate number are identical. }

Use the following files:

AutoTester.java

public class AutoTester
{
   public static void main(String[] args)
   {
      Vehicle auto1 = new Auto("1234567890", "A141G3");
      Vehicle auto2 = new Auto("1234567890", "5ZSN090");
      Vehicle auto3 = new Auto("14916253649", "A141G3");
      Vehicle auto4 = new Auto("1234567890", "A141G3");
      System.out.println(auto1.equals(auto1));
      System.out.println("Expected: true");
      System.out.println(auto1.equals(auto2));
      System.out.println("Expected: false");
      System.out.println(auto1.equals(auto3));
      System.out.println("Expected: false");
      System.out.println(auto1.equals(auto4));
      System.out.println("Expected: true");
   }
}

Vehicle.java

/**
   Represents a vehicle of any type.
*/
public class Vehicle
{
   private String id;

   public Vehicle(String anId)
   {
      id = anId;
   }
   
   public boolean equals(Object otherObject)
   {
      Vehicle other = (Vehicle) otherObject;
      return id.equals(other.id);
   }
}