Problem

Modify the driver program from practice program.To use three exception classes called Cy...

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);	 }     }

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT