Question: Create a base class called Vehicle that has the manufacturer's name ( type String ), number of cylinders in the engine (type int), and ower
Create a base class called Vehicle that has the manufacturer's name ( type String ), number of cylinders in the engine (type int), and ower (type Person given below). Then create a class called Truck that is derived from Vehicle and has additional properties: the load capacity in tons (type double, since it may contain a frational part) and towing capacity in tons (type double) . give your classes a reasonable complement of contructors and accessor methods, and an equals method as well. Write a driver program that tests all your methods. 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); } }
************Output needs to look like this

pl: pl's name is Bob p2: Joe p3 equal to pl: true p2 equal to pl: false v1: None 0 cylinders owned by v1's manufacturer is: Ford v1's cylinders 4 v1's owner is: Joe v2: Chevy, 4 cylinders owned by Betty v3 equal to v1. true v2 equal to v1. false ti: None 0 cylinders owned by load capacity 0.0 towing capacity 0 ti's load capacity is 54.36 tl's towing capacity is 10 t2: Chevy 4 cylinders owned by Betty, load capacity 34.5, towing capacity 65 3 equal to t1 true t2 equal to t1. false BUILD SUCCESSFUL (total time: 0 seconds
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
