Create a base class called Vehicle that has the manufacturer's name (type String), number of cylinders in

Question:

Create a base class called Vehicle that has the manufacturer's name (type String), number of cylinders in the engine (type int), and owner (type Person given in Listing 8.1Truck that is derived from Vehicle and has additional properties: the load capacity in tons (type double, since it may contain a fractional part) and towing capacity in tons (type double). Give your classes a reasonable complement of constructors and accessor methods, and an equals method as well. Write a driver program (no pun intended) that tests all your methods.
Listing 8.1
Person Class
public class Person
{
String name;
public Person( )
{
name = "No name yet";
}
public Person(String initialName)
{
name = initialName;
}
public void setName(String newName)
{
name = newName;
}
public String getName( )
{
return name;
}
public void writeOutput( )
{
System.out.println("Name: " + name);
}
public boolean hasSameName(Person otherPerson)
{
return this.name.equalsIgnoreCase(otherPerson.name);
}
}
Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: