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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

 
public class Auto extends Vehicle
{
private String license Plate;
public Auto (String vin, String plate)
{
}
}
// TODO: Override the equals method of the Object class to
// test that VIN and license plate number are identical.
}
er.java
public class AutoTester
{
public static void main(String[] args)
{
}
super (vin);
licensePlate plate;
va
✓**
Vehicle autol = 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(autol.equals (autol));
System.out.println("Expected: true");
System.out.println(autol.equals (auto2));
System.out.println("Expected: false");
System.out.println(autol.equals (auto3));
System.out.println("Expected: false");
System.out.println(autol.equals (auto4));
System.out.println("Expected: true");
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);
Transcribed Image Text:public class Auto extends Vehicle { private String license Plate; public Auto (String vin, String plate) { } } // TODO: Override the equals method of the Object class to // test that VIN and license plate number are identical. } er.java public class AutoTester { public static void main(String[] args) { } super (vin); licensePlate plate; va ✓** Vehicle autol = 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(autol.equals (autol)); System.out.println("Expected: true"); System.out.println(autol.equals (auto2)); System.out.println("Expected: false"); System.out.println(autol.equals (auto3)); System.out.println("Expected: false"); System.out.println(autol.equals (auto4)); System.out.println("Expected: true"); 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);
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education