Modify the driver program from practice program.To use three exception classes called CylinderException, LoadException, andTowingException. The number of cylinders must be an integer from 1to 12, the load capacity must be a number from 1 to 10 (possibly with afractional part), and the towing capacity must be a number from 1 to 20(possibly with a fractional part). Anything other than numbers in theseranges should cause your program to throw and catch the appropriateexception. You also need to define the classes CylinderException,LoadException, and TowingException.
Create a base class called Vehicle that has the manufacturer′s name (typeString), number of cylinders in the engine (type int), and owner (typePerson given in Listing). T hen create a class called Truck that is derivedfrom Vehicle and has additional properties: the load capacity in tons (typedouble, since it may contain a fractional part) and towing capacity in tons(type double). Give your classes a reasonable complement of constructorsand accessor methods, and an equals method as well. Write a driver program(no pun intended) that tests all your methods.
public class Person { private 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); } }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.