The instructions for this program are to find a way to make it display both the letter grade and the score but I have no idea how to do it without completely defeating the point of the interface. If anyone knows a way to do this I would really appreciate the help.
public class Quiz implements Measurable { public Quiz(double initialScore, String initialLetter) { score = initialScore; letter = initialLetter; } public Object measure() { return score; } public Object measure2() { return letter; } private double score; private String letter; } public interface Measurable { Object measure(); } public class DataSet { public DataSet() { sum = 0; i = 0; maximum = null; } public void add(Measurable x) { sum += (double) x.measure(); if (i == 0 || (double) maximum.measure() < (double) x.measure()) { maximum = x; } i++; } public double getAverage() { return sum / i; } public Measurable getMaximum() { return maximum; } private Measurable maximum; private double sum; private int i; } public class DataSetTester { public static void main(String[] args) { DataSet data = new DataSet(); data.add(new Quiz(.98, "A")); data.add(new Quiz(.90, "A")); data.add(new Quiz(.85, "B")); data.add(new Quiz(.28, "F")); data.add(new Quiz(.91, "A")); System.out.println(data.getAverage()); System.out.println(data.getMaximum().measure()); } }