Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Start with the DataSet class and make it into a generic DataSetGen class. Test it with the DataSetTester. The DataSetTester uses the BankAccount and BaseballPlayer
Start with the DataSet class and make it into a generic DataSetGen class. Test it with the DataSetTester. The DataSetTester uses the BankAccount and BaseballPlayer classes. Do not change any of the classes except DataSet. Upload your DataSetGen.java.
only the below class needs to be converted into a generic class
dataset
/** Computes the average of a set of data values. */ public class DataSet { private double sum; private Measurable maximum; private int count; /** Constructs an empty data set. */ public DataSet() { sum = 0; count = 0; maximum = null; } /** Adds a data value to the data set. @param x a data value */ public void add(Measurable x) { sum = sum + x.getMeasure(); if (count == 0 || maximum.getMeasure() < x.getMeasure()) 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 Measurable getMaximum() { return maximum; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started