Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java, show all code and specifically for methods in step 5 Write a Java interface called Measurable. The idea here is that a Measurable object

Java, show all code and specifically for methods in step 5

image text in transcribed

Write a Java interface called "Measurable". The idea here is that a Measurable object should be able to supply a numerical value (it's measure). The meaning of the measure will vary, depending on the class of the object. The Measurable interface should contain two method prototypes (copy and paste these into your interface) public double getMeasure(); public String getDescription(); Write the following classes -- each must implement the Measurable interface. For each class, include a constructor (with two parameters) that allows the user to quickly initialize the state of the object: A class called Person. A person will have an instance variable (String) for the person's name, and a double variable for their height. The getMeasure method will return their height, and getDescription will return their name. A class called Song. A song will have an instance variable (String) for its title (which will serve as the "description") and a double variable for its duration (which will serve as its "measure"). Write a class called Measure Tools, that includes a main method along with the following static methods: public static double getAverageMeasure(Measurable[] list) {...} This method should compute the average of the measures of all of the items in the array. public static String getDescriptionOfLargest Thing (Measurable[] list) {...} This method should find the object in the list with the largest measure, and return it's description. Fill in the main method so that it will do the following: Instantiate an array of type Measurable, length 3. Fill the array with 3 Persons. Call both getAverageMeasure and getDescriptionOfLargest Thing on your array, printing the results of each method call. Fill the array with 3 Songs. Call both getAverageMeasure and getDescriptionOfLargest Thing on your array, printing the results. Run it

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions