Reference no: EM13939841
Using a different Measurer object, process a set of Rectangle objects to find the rectangle with the largest perimeter.
You need to supply the following class in your solution:
PerimeterMeasurer
Use the following class as your tester class:
import java.awt.Rectangle;
/**
This program tests the measurement of rectangles by perimeter.
*/
public class PerimeterTester
{
public static void main(String[] args)
{
DataSet data = . . .;
data.add(new Rectangle(5, 10, 20, 30));
data.add(new Rectangle(10, 20, 30, 40));
data.add(new Rectangle(20, 30, 5, 10));
double avg = . . .;
Rectangle max = . . .;
System.out.println("Average perimeter: " + avg);
System.out.println("Expected: ");
System.out.println("Largest perimeter: " + max);
System.out.println("Expected: ");
}
}
/**
Computes the average of a set of data values.
*/
public class DataSet
{
private double sum;
private Object maximum;
private int count;
private Measurer measurer;
/**
Constructs an empty data set with a given measurer.
@param aMeasurer the measurer that is used to measure data values
*/
public DataSet(Measurer aMeasurer)
{
sum = 0;
count = 0;
maximum = null;
measurer = aMeasurer;
}
/**
Adds a data value to the data set.
@param x a data value
*/
public void add(Object x)
{
sum = sum + measurer.measure(x);
if (count == 0
|| measurer.measure(maximum) < measurer.measure(x))
maximum = x;
count++;
}
/**
Gets the average of the added data.
@return the average or 0 if no data has been added
*/
public double getAverage()
{
if (count == 0) return 0;
else return sum / count;
}
/**
Gets the largest of the added data.
@return the maximum or 0 if no data has been added
*/
public Object getMaximum()
{
return maximum;
}
}
/**
Describes any class whose objects can measure other objects.
*/
public interface Measurer
{
/**
Computes the measure of an object.
@param anObject the object to be measured
@return the measure
*/
double measure(Object anObject);
}
Cost accounting systems used by manufacturing
: Cost accounting systems used by manufacturing companies are based on the: Periodic inventory system.
|
Issued dividend of per share on its common stock
: The Muse Co. just issued a dividend of $3.45 per share on its common stock. The company is expected to maintain a constant 7.10 percent growth rate in its dividends indefinitely. If the stock sells for $69 a share, what is the company’s cost of equit..
|
Discuss your reaction to the public service announcement
: Discuss your reaction to the public service announcement in relation to the marketing of junk food to children, with a focus on why or why not this PSA is appropriate.
|
Implications relative to religious freedom of employers
: Does the Hobby Lobby decision have other implications relative to religious freedom of employers? If so, what might they be?
|
Computes the measure of an object.
: This program tests the measurement of rectangles by perimeter.
|
What is the expected return on your portfolio
: You analyze the prospects of several companies and come to the following conclusions about the expected return on each: You decide to invest $4,000 in star bucks, $6,000 in Sears, $12,000 in Microsoft, and $3,000 in Limited Brands. What is the expect..
|
Point estimate of the proportion of selling company
: Provide a point estimate of the proportion of selling company's stock which is obsolete. To give a measure of the uncertainty in this estimate, construct a 90% confidence interval for the true proportion of stock which is obsolete.
|
What measures company must take to capture any reductions
: Calculate the nonvalue-added usage and costs for materials usage and sustaining engineering. In particular, discuss what measures the company must take to capture any realized reductions in resource usage.
|
Recommend options that would be consistent with organization
: Recommend options that would be consistent with the organization's accounting practices, accounting processes, and accounting-relateddepartments.
|