1 package com.changenode;
2
3 import java.util.EventListener;
4 import java.util.StringTokenizer;
5
6 /**
7 * Simple Calculator for demonstration purposes.
8 */
9 public class Calculator {
10
11 private double state;
12
13 /**
14 *
15 * @param value to add to register
16 * @return the original Calculator object
17 */
18 public Calculator add(double value) {
19 state += value;
20 return this;
21 }
22
23 /**
24 *
25 * @param value to subtract from the register
26 * @return the original Calculator object
27 */
28 public Calculator subtract(double value) {
29 state -= value;
30 return this;
31 }
32
33 /**
34 *
35 * @param value to multiply the register by
36 * @return the original Calculator object
37 */
38 public Calculator multiply(double value) {
39 state = state * value;
40 return this;
41 }
42
43 /**
44 *
45 * @param value to divide the register by
46 * @return the original Calculator object
47 */
48 public Calculator divide(double value) {
49 state = state / value;
50 return this;
51 }
52
53 /**
54 *
55 * @return current value of the register
56 */
57 public double value() {
58 return state;
59 }
60
61 /**
62 *
63 * @param value to apply transwarp value
64 * @return the original Calculator object
65 */
66 public Calculator transwarp(double value) {
67
68 // TODO figure out the transwarp requirements.
69 throw new UnsupportedOperationException("No transwarp defined.");
70 }
71
72 /**
73 *
74 * Method intended to trip the PMD violations error. Hopefully you find this method as horrifying as I do even without PMD.
75 *
76 * @param foo random string
77 * @param bar random string
78 * @param spam untyped Object FTW
79 * @param eventListener some kind of events...?
80 * @param stringTokenizer because why not?
81 * @return some number
82 */
83 public int arbitrarilyComplexMethod(String foo, int bar, Object spam, EventListener eventListener, StringTokenizer stringTokenizer) {
84
85 try {
86 System.out.println(foo);
87 } catch (Exception e) {
88
89 }
90
91 try {
92 System.out.println(foo);
93 } catch (Exception e) {
94
95 }
96
97
98 if (foo == "bar")
99 return 0;
100
101 if (bar++ == -100)
102 return Long.BYTES;
103
104 return Integer.valueOf(foo + bar + spam.toString() + eventListener.toString() + stringTokenizer.toString());
105 }
106
107 /**
108 * Method intended to trip the CPM violations error
109 *
110 * @param foo random string
111 * @param bar random string
112 * @param spam untyped Object FTW
113 * @param eventListener some kind of events...?
114 * @param stringTokenizer because why not?
115 * @return some number
116 */
117 public int arbitrarilyComplexMethodPart2(String foo, int bar, Object spam, EventListener eventListener, StringTokenizer stringTokenizer) {
118 try {
119 System.out.println(foo);
120 } catch (Exception e) {
121
122 }
123
124 try {
125 System.out.println(foo);
126 } catch (Exception e) {
127
128 }
129
130 if (foo == "bar")
131 return 0;
132
133 if (bar++ == -100)
134 return Long.BYTES;
135
136 return Integer.valueOf(foo + bar + spam.toString() + eventListener.toString() + stringTokenizer.toString());
137 }
138
139 }