1 import java.awt.Rectangle;
2
3 /**
4 This program demonstrates the use of a Measurer.
5 */
6 public class DataSetTester2
7 {
8 public static void main(String[] args)
9 {
10 Measurer m = new RectangleMeasurer();
11
12 DataSet data = new DataSet(m);
13
14 data.add(new Rectangle(5, 10, 20, 30));
15 data.add(new Rectangle(10, 20, 30, 40));
16 data.add(new Rectangle(20, 30, 5, 15));
17
18 System.out.println("Average area: " + data.getAverage());
19 System.out.println("Expected: 625");
20
21 Rectangle max = (Rectangle) data.getMaximum();
22 System.out.println("Maximum area rectangle: " + max);
23 System.out.println("Expected: "
24 + "java.awt.Rectangle[x=10,y=20,width=30,height=40]");
25 }
26 }