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