It's Java; the code should be the same as the output sample below; please, thank you. Note:...

60.1K

Verified Solution

Question

Programming

It's Java; the code should be the same as the output samplebelow; please, thank you.

Note: create a single-file solution that has multipleclass definitions. Also, note that the static main() method shouldbe a member of the Vehicle class.

Create a class called Vehicle that has the manufacturers name(type String), number of cylinders in the engine (type int), andowner (type Person given next). Then, create a class called Truckthat is derived from Vehicle and has the following additionalproperties: the load capacity in tons (type double since it maycontain a fractional part) and towing capacity in pounds (typeint). Be sure your class has a reasonable complement ofconstructors, accessor and mutator methods, and suitably definedequals and toString methods. Write a program to test all yourmethods (see sample run).

The definition of the class Person follows. Completing thedefinitions of the methods is part of this programmingproject.

class Person{
private String name;
public Person()
{...}
public Person(String theName)
{...}
public Person(Person theObject)
{...}
public String getName()
{...}
public void setName(String theName)
{...}
public String toString()
{...}
public boolean equals(Object other)
{...}
}

Output sample: interactive session

Enter·manufacturar·name:Chevrolet↵ Enter·number·of·cylinders:8↵Enter·owner·name:David↵ Enter·load:2800.0↵Enter·towing·capacity:1000↵Enter·1·to·change·vehicle·properties,·2·to·print·and·10·to·quit:2↵main↵Manufacturer:·Chevrolet·Cylinders:·8·Name:·David·Load·Capacity:·2800.0·lbs·Tow·Capacity:·1000·pounds↵Enter·1·to·change·vehicle·properties,·2·to·print·and·10·to·quit:1↵Enter·1·to·change·manufacturar,·2·to·change·cylinders,·3·to·change·owner,·4·to·change·load,·5·to·change·towing·capacity,·or·any·other·number·to·go·back·to·main·menu:4↵Enter·load:50000↵Enter·1·to·change·vehicle·properties,·2·to·print·and·10·to·quit:1↵Enter·1·to·change·manufacturar,·2·to·change·cylinders,·3·to·change·owner,·4·to·change·load,·5·to·change·towing·capacity,·or·any·other·number·to·go·back·to·main·menu:5↵Enter·towing·capacity:1000↵Enter·1·to·change·vehicle·properties,·2·to·print·and·10·to·quit:2↵main↵Manufacturer:·Chevrolet·Cylinders:·8·Name:·David·Load·Capacity:·50000.0·lbs·Tow·Capacity:·1000·pounds↵Enter·1·to·change·vehicle·properties,·2·to·print·and·10·to·quit:10↵↵

Answer & Explanation Solved by verified expert
3.7 Ratings (280 Votes)
Note Here whole code and class is done as per your request but if you have any doubt or issue regarding this you can ask me or post the issue i will change code according to your need Alos include try catch exception for better run the code personjava public class Person private String name private Person obj public Person public PersonString theName thisname theName public PersonPerson theObject thisobj theObject public String getName return name public void setNameString name thisname name Override public boolean equalsObject obj return superequalsobj Override public String toString return Owner name n Truckjava public class Truck extends Vehicle private double loadCapacity private int towingCapacity public    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students