// Author: Torben Hoffmann ? // Modified by: Anders Keldsen and Anne Haxthausen 14 October 2002 public class TestTime { public static void main (String[] args) { boolean testPassed; Time t1= new Time(11,10); Time t2= new Time(20, 0); boolean test1 = (t1.to(t2)==530); testPassed = test1; System.out.println("There is 530 minutes from " + t1 + " to " + t2 + ":" + test1); boolean test2 = t1.before(t2); testPassed = testPassed && test2; System.out.println(t1 +" is before " + t2 + ": " + test2); Time t3 = t1.plus(90); Time t4 = new Time (12,40); boolean test3 = t3.toString().equals(t4.toString()); testPassed = testPassed && test3; System.out.println(t1 + " plus 90 minutes is 12.40: " + test3); String timeBefore = t1.toString(); t1.passtime(90); boolean test4 = t1.toString().equals(t4.toString()); testPassed = testPassed && test4; System.out.println("after having moved t1 (" + timeBefore + ") 90 minutes forward, it shows 12.40: " + test4); Time t5 = t2.plus(400); Time t6 = new Time(2,40); boolean test5 = t5.toString().equals(t6.toString()); testPassed = testPassed && test5; System.out.println(t2 + " plus 400 minutes is 02.40: " + test5); timeBefore = t2.toString(); t2.passtime(400); boolean test6 = t2.toString().equals(t6.toString()); testPassed = testPassed && test6; System.out.println("after having moved t2 (" + timeBefore + ") 400 minutes forward, it shows 02.40: " + test6); boolean test7 = (t1.before(t2) == false); testPassed = testPassed && test7; System.out.println("t1 (" + t1 + ") is no longer before t2 (" + t2 + "): " + test7 ); if (testPassed) System.out.println("Congratulations. Your own Time class" + " passed the test!"); else System.out.println("Sorry. There is an error in " + "your Time class."); } }