Question: JAVA ONLY Assume that there is a Java interface named Measurable. The only method in the interface is method getMeasure(), which returns a string describing
JAVA ONLY
Assume that there is a Java interface named Measurable. The only method in the interface is method getMeasure(), which returns a string describing an objects measurement (if of type Measurement). Assume that there are three classes of type Measureable: Rectangle (with measurement height and width, in inches), Package (with measurement of weight in lbs and ounces), and WindSpeed (with measurement in miles per hour). Give sufficient code to demonstrate the use of polymorphism involving objects of each of these three types. (6 pts.)
Declare an interface named Sized, containing only one method, getSize, that returns a string. Assume
that there exist a number of classes declared of type Sized in a particular application, specifically, StudentRecords (where size is the number of records), SemesterSchedule (where size it the number of credits taking), Department (where size is the number of faculty in a particular department), and Building (where size is the total number of square feet). (10 pts.)
Also declare a checked exception named UnsizedException.
Create a class named Measurements that contains just one static method named getSize that takes as an argument an object of any type (and returns a string type) and does the following:
If the object is of type String or StringBuffer, then returns a string of the form 16 characters
If the object is of type Sized, and also of type
StudentRecords, then returns a string of the form
SemesterSchedule, then returns a string of the form 16 credits
Department, then returns a string of the form 28 faculty members
Building, then returns a string of the form 8560 square feet
Otherwise, an UnsizedException is thrown.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
