// test program #2 // SimpleClasses.txt - tests method calls and dispatch. public class SimpleClasses { public SimpleClasses() { super(); } public static void main() { JFSystem sys; IceCream i1; IceCream i2; Sundae s; // Create objects sys = new JFSystem(); i1 = new IceCream(sys); i2 = new Sundae(sys); s = new Sundae(sys); // Call the print methods i1.howManyCalories(500,400); // Should print 100 i2.howManyCalories(50,-2); // Should print 156 s.howManyCalories(6,11); // Should print -15 } } public class IceCream { public JFSystem mySys; public IceCream(JFSystem sys) { super(); mySys = sys; } public int foo(int a) { return a; } public void howManyCalories(int a, int b) { mySys.put(a-b); } public int hoo(int b) { return b; } } public class Sundae extends IceCream { public Sundae(JFSystem sys) { super(sys); } public void boo() { mySys.put(0); mySys.put(0); mySys.put(0); } public void howManyCalories(int a, int b) { mySys.put((a-b)*3); } }