| 71 | } |
| 72 | |
| 73 | private static void perform(Calculator.Client client) throws TException |
| 74 | { |
| 75 | client.ping(); |
| 76 | System.out.println("ping()"); |
| 77 | |
| 78 | int sum = client.add(1,1); |
| 79 | System.out.println("1+1=" + sum); |
| 80 | |
| 81 | Work work = new Work(); |
| 82 | |
| 83 | work.op = Operation.DIVIDE; |
| 84 | work.num1 = 1; |
| 85 | work.num2 = 0; |
| 86 | try { |
| 87 | int quotient = client.calculate(1, work); |
| 88 | System.out.println("Whoa we can divide by 0"); |
| 89 | } catch (InvalidOperation io) { |
| 90 | System.out.println("Invalid operation: " + io.why); |
| 91 | } |
| 92 | |
| 93 | work.op = Operation.SUBTRACT; |
| 94 | work.num1 = 15; |
| 95 | work.num2 = 10; |
| 96 | try { |
| 97 | int diff = client.calculate(1, work); |
| 98 | System.out.println("15-10=" + diff); |
| 99 | } catch (InvalidOperation io) { |
| 100 | System.out.println("Invalid operation: " + io.why); |
| 101 | } |
| 102 | |
| 103 | SharedStruct log = client.getStruct(1); |
| 104 | System.out.println("Check log: " + log.value); |
| 105 | } |
| 106 | } |