Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to: a) Write a BowlingGame class per the UML diagram below. MeasurableDem

ID: 669593 • Letter: I

Question

I need to:

a) Write a BowlingGame class per the UML diagram below.

MeasurableDemo -------------------> <<interface>> Measurable

BowlingGame ----------------------------> double.getMeasure()

MeasurableDemo -------------------> intscore

BowlingGame(int inScore)

int getscore()

b) Complete the MeasurableDemo.java class as directed in the code comments.

c) Modify BowlingGame to implement the Comparable interface and illustrate its correct implementation by modifying the MeasurableDemo to sort the array. (Printout array before and after call to sort.)

Here are the codes, what do I do? Please and Thanks!

Measurable.java

/**
Describes any class whose objects can be measured.
*/
public interface Measurable
{
/**
Computes the measure of the object.
@return the measure
*/
double getMeasure();
}

MeasurableDemo.java

/**
This program demonstrates the measurable interface for Bowling Games.
*/
public class MeasurableDemo
{
public static void main(String[] args)
{
   // TODO: Create an array of 3 bowling games and populate with scores of your choice.
  
  
   // TODO: printout the average of these scores by calling the average method below

}

/**
Computes the average of the measures of the given objects.
@param objects an array of Measurable objects
@return the average of the measures
*/
public static double average(Measurable[] objects)
{
if (objects.length == 0) { return 0; }
double sum = 0;
for (Measurable obj : objects)
{
sum = sum + obj.getMeasure();
}
return sum / objects.length;
}
}

Explanation / Answer

Measurable.java /** Describes any class whose objects can be measured. */ public interface Measurable { /** Computes the measure of the object. @return the measure */ double getMeasure(); } public class MeasurableDemo { public static void main(String[] args) { Measurable[] accounts = new Measurable[3]; accounts[0] = new BankAccount(0); accounts[1] = new BankAccount(10000); accounts[2] = new BankAccount(2000); System.out.println("Average balance: " + average(accounts)); Measurable[] countries = new Measurable[3]; countries[0] = new Country("Uruguay", 176220); countries[1] = new Country("Thailand", 514000); countries[2] = new Country("Belgium", 30510); System.out.println("Average area: " + average(countries)); } /** Computes the average of the measures of the given objects. @param objects an array of Measurable objects @return the average of the measures */ public static double average(Measurable[] objects) { if (objects.length == 0) { return 0; } double sum = 0; for (Measurable obj : objects) { sum = sum + obj.getMeasure(); } return sum / objects.length; } }