1 public class ComparisonTest { 2 3 public boolean equals(int x, int y) { 4 if (x == y) { 5 return true; 6 } else { 7 return false; 8 } 9 } 10 11 public boolean lessThan(int x, int y) { 12 if (x < y) { 13 return true; 14 } else { 15 return false; 16 } 17 } 18 19 public boolean greaterThan(int x, int y) { 20 if (x > y) { 21 return true; 22 } else { 23 return false; 24 } 25 } 26 27 public static void main(String[] args) { 28 ComparisonTest test = new ComparisonTest(); 29 if (test.equals(1, -1)) { 30 System.err.println("test.equals(1, -1) failed!"); 31 } else { 32 System.out.println("test.equals(1, -1) correct: " + test.equals(1, -1)); 33 } 34 if (!test.equals(10, 10)) { 35 System.err.println("test.equals(10, 10) failed!"); 36 } else { 37 System.out.println("test.equals(10, 10) correct: " + test.equals(10, 10)); 38 } 39 if (test.lessThan(1, -1)) { 40 System.err.println("test.lessThan(1, -1) failed!"); 41 } else { 42 System.out.println("test.lessThan(1, -1) correct: " + test.lessThan(1, -1)); 43 } 44 if (!test.lessThan(1, 15)) { 45 System.err.println("test.lessThan(1, 15) failed!"); 46 } else { 47 System.out.println("test.lessThan(1, 15) correct: " + test.lessThan(1, 15)); 48 } 49 if (test.greaterThan(23, 29)) { 50 System.err.println("test.greaterThan(23, 29) failed!"); 51 } else { 52 System.out.println("test.greaterThan(23, 29) correct: " + test.greaterThan(23, 29)); 53 } 54 if (!test.greaterThan(-23, -29)) { 55 System.err.println("test.greaterThan(-23, -29) failed!"); 56 } else { 57 System.out.println("test.greaterThan(-23, -29) correct: " + test.greaterThan(-23, -29)); 58 } 59 } 60 } 61 62 // vim: tabstop=4 expandtab shiftwidth=4