Procházet zdrojové kódy

Java Fundamentals (All tests passed)

Jennifer Chao před 6 roky
rodič
revize
67e7615f74
27 změnil soubory, kde provedl 1533 přidání a 59 odebrání
  1. binární
      Dan Do Better/MathUtilities.class
  2. 82
    0
      Dan Do Better/MathUtilities.ctxt
  3. 247
    0
      Dan Do Better/MathUtilities.java
  4. binární
      Dan Do Better/PredicateUtilities.class
  5. 16
    0
      Dan Do Better/PredicateUtilities.ctxt
  6. 69
    0
      Dan Do Better/PredicateUtilities.java
  7. 12
    0
      Dan Do Better/README.TXT
  8. binární
      Dan Do Better/StringUtilities.class
  9. 34
    0
      Dan Do Better/StringUtilities.ctxt
  10. 114
    0
      Dan Do Better/StringUtilities.java
  11. binární
      Dan Do Better/TestMathUtilities.class
  12. 56
    0
      Dan Do Better/TestMathUtilities.ctxt
  13. 342
    0
      Dan Do Better/TestMathUtilities.java
  14. binární
      Dan Do Better/TestPredicateUtilities.class
  15. 20
    0
      Dan Do Better/TestPredicateUtilities.ctxt
  16. 120
    0
      Dan Do Better/TestPredicateUtilities.java
  17. binární
      Dan Do Better/TestStringUtilities.class
  18. 28
    0
      Dan Do Better/TestStringUtilities.ctxt
  19. 174
    0
      Dan Do Better/TestStringUtilities.java
  20. binární
      Dan Do Better/ZipcodeRocks.class
  21. 6
    0
      Dan Do Better/ZipcodeRocks.ctxt
  22. 8
    0
      Dan Do Better/ZipcodeRocks.java
  23. 86
    0
      Dan Do Better/package.bluej
  24. 48
    41
      src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java
  25. 32
    5
      src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java
  26. 38
    12
      src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java
  27. 1
    1
      src/main/java/com/zipcodewilmington/danny_do_better_exercises/ZipcodeRocks.java

binární
Dan Do Better/MathUtilities.class Zobrazit soubor


+ 82
- 0
Dan Do Better/MathUtilities.ctxt Zobrazit soubor

@@ -0,0 +1,82 @@
1
+#BlueJ class context
2
+comment0.target=MathUtilities
3
+comment0.text=\n\ Created\ by\ dan\ on\ 6/14/17.\n
4
+comment1.params=baseValue\ difference
5
+comment1.target=java.lang.Integer\ add(int,\ int)
6
+comment1.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
7
+comment10.params=baseValue\ difference
8
+comment10.target=java.lang.Byte\ subtract(byte,\ byte)
9
+comment10.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ subtract\ from\ starting\ value\n\ @return\ difference\ between\ `baseValue`\ and\ `difference`\n
10
+comment11.params=baseValue\ difference
11
+comment11.target=java.lang.Float\ subtract(float,\ float)
12
+comment11.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ subtract\ from\ starting\ value\n\ @return\ difference\ between\ `baseValue`\ and\ `difference`\n
13
+comment12.params=baseValue\ difference
14
+comment12.target=java.lang.Double\ subtract(double,\ double)
15
+comment12.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ subtract\ from\ starting\ value\n\ @return\ difference\ between\ `baseValue`\ and\ `difference`\n
16
+comment13.params=dividend\ divisor
17
+comment13.target=java.lang.Integer\ divide(int,\ int)
18
+comment13.text=\n\ @param\ dividend\ value\ to\ be\ divided\n\ @param\ divisor\ \ value\ to\ divide\ by\n\ @return\ division\ of\ `dividend`\ by\ `divisor\n
19
+comment14.params=dividend\ divisor
20
+comment14.target=java.lang.Long\ divide(long,\ long)
21
+comment14.text=\n\ @param\ dividend\ value\ to\ be\ divided\n\ @param\ divisor\ \ value\ to\ divide\ by\n\ @return\ division\ of\ `dividend`\ by\ `divisor\n
22
+comment15.params=dividend\ divisor
23
+comment15.target=java.lang.Short\ divide(short,\ short)
24
+comment15.text=\n\ @param\ dividend\ value\ to\ be\ divided\n\ @param\ divisor\ \ value\ to\ divide\ by\n\ @return\ division\ of\ `dividend`\ by\ `divisor\n
25
+comment16.params=dividend\ divisor
26
+comment16.target=java.lang.Byte\ divide(byte,\ byte)
27
+comment16.text=\n\ @param\ dividend\ value\ to\ be\ divided\n\ @param\ divisor\ \ value\ to\ divide\ by\n\ @return\ division\ of\ `dividend`\ by\ `divisor\n
28
+comment17.params=dividend\ divisor
29
+comment17.target=java.lang.Float\ divide(float,\ float)
30
+comment17.text=\n\ @param\ dividend\ value\ to\ be\ divided\n\ @param\ divisor\ \ value\ to\ divide\ by\n\ @return\ division\ of\ `dividend`\ by\ `divisor\n
31
+comment18.params=dividend\ divisor
32
+comment18.target=java.lang.Double\ divide(double,\ double)
33
+comment18.text=\n\ @param\ dividend\ value\ to\ be\ divided\n\ @param\ divisor\ \ value\ to\ divide\ by\n\ @return\ division\ of\ `dividend`\ by\ `divisor\n
34
+comment19.params=multiplicand\ multiplier
35
+comment19.target=java.lang.Integer\ multiply(int,\ int)
36
+comment19.text=\n\ @param\ multiplicand\ value\ to\ be\ multiplied\n\ @param\ multiplier\ \ \ value\ to\ multiply\ by\n\ @return\ product\ of\ `multiplicand`\ by\ `multiplier`\n
37
+comment2.params=baseValue\ difference
38
+comment2.target=java.lang.Long\ add(long,\ long)
39
+comment2.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
40
+comment20.params=multiplicand\ multiplier
41
+comment20.target=java.lang.Long\ multiply(long,\ long)
42
+comment20.text=\n\ @param\ multiplicand\ value\ to\ be\ multiplied\n\ @param\ multiplier\ \ \ value\ to\ multiply\ by\n\ @return\ product\ of\ `multiplicand`\ by\ `multiplier`\n
43
+comment21.params=multiplicand\ multiplier
44
+comment21.target=java.lang.Short\ multiply(short,\ short)
45
+comment21.text=\n\ @param\ multiplicand\ value\ to\ be\ multiplied\n\ @param\ multiplier\ \ \ value\ to\ multiply\ by\n\ @return\ product\ of\ `multiplicand`\ by\ `multiplier`\n
46
+comment22.params=multiplicand\ multiplier
47
+comment22.target=java.lang.Byte\ multiply(byte,\ byte)
48
+comment22.text=\n\ @param\ multiplicand\ value\ to\ be\ multiplied\n\ @param\ multiplier\ \ \ value\ to\ multiply\ by\n\ @return\ product\ of\ `multiplicand`\ by\ `multiplier`\n
49
+comment23.params=multiplicand\ multiplier
50
+comment23.target=java.lang.Float\ multiply(float,\ float)
51
+comment23.text=\n\ @param\ multiplicand\ value\ to\ be\ multiplied\n\ @param\ multiplier\ \ \ value\ to\ multiply\ by\n\ @return\ product\ of\ `multiplicand`\ by\ `multiplier`\n
52
+comment24.params=multiplicand\ multiplier
53
+comment24.target=java.lang.Double\ multiply(double,\ double)
54
+comment24.text=\n\ @param\ multiplicand\ value\ to\ be\ multiplied\n\ @param\ multiplier\ \ \ value\ to\ multiply\ by\n\ @return\ product\ of\ `multiplicand`\ by\ `multiplier`\n
55
+comment25.params=
56
+comment25.target=java.lang.Boolean\ returnTrue()
57
+comment25.text=\n\ @return\ true\n
58
+comment26.params=
59
+comment26.target=java.lang.Boolean\ returnFalse()
60
+comment26.text=\n\ @return\ false\n
61
+comment3.params=baseValue\ difference
62
+comment3.target=java.lang.Short\ add(short,\ short)
63
+comment3.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
64
+comment4.params=baseValue\ difference
65
+comment4.target=java.lang.Byte\ add(byte,\ byte)
66
+comment4.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
67
+comment5.params=baseValue\ difference
68
+comment5.target=java.lang.Float\ add(float,\ float)
69
+comment5.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
70
+comment6.params=baseValue\ difference
71
+comment6.target=java.lang.Double\ add(double,\ double)
72
+comment6.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
73
+comment7.params=baseValue\ difference
74
+comment7.target=java.lang.Integer\ subtract(int,\ int)
75
+comment7.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ subtract\ from\ starting\ value\n\ @return\ difference\ between\ `baseValue`\ and\ `difference`\n
76
+comment8.params=baseValue\ difference
77
+comment8.target=java.lang.Long\ subtract(long,\ long)
78
+comment8.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ subtract\ from\ starting\ value\n\ @return\ difference\ between\ `baseValue`\ and\ `difference`\n
79
+comment9.params=baseValue\ difference
80
+comment9.target=java.lang.Short\ subtract(short,\ short)
81
+comment9.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ subtract\ from\ starting\ value\n\ @return\ difference\ between\ `baseValue`\ and\ `difference`\n
82
+numComments=27

+ 247
- 0
Dan Do Better/MathUtilities.java Zobrazit soubor

@@ -0,0 +1,247 @@
1
+/**
2
+ * Created by dan on 6/14/17.
3
+ */
4
+public class MathUtilities {
5
+
6
+    /**
7
+     * @param baseValue  starting value
8
+     * @param difference value to add to starting value
9
+     * @return sum of `baseValue` and `difference`
10
+     */
11
+    public Integer add(int baseValue, int difference) {
12
+        return (baseValue + difference);
13
+    }
14
+
15
+    /**
16
+     * @param baseValue  starting value
17
+     * @param difference value to add to starting value
18
+     * @return sum of `baseValue` and `difference`
19
+     */
20
+    public Long add(long baseValue, long difference) {
21
+        return baseValue + difference;
22
+    }
23
+
24
+    /**
25
+     * @param baseValue  starting value
26
+     * @param difference value to add to starting value
27
+     * @return sum of `baseValue` and `difference`
28
+     */
29
+    public Short add(short baseValue, short difference) {
30
+        short sumShort = (short) (baseValue + difference);
31
+        return sumShort;
32
+    }
33
+
34
+    /**
35
+     * @param baseValue  starting value
36
+     * @param difference value to add to starting value
37
+     * @return sum of `baseValue` and `difference`
38
+     */
39
+    public Byte add(byte baseValue, byte difference) {
40
+        byte sumByte = (byte) (baseValue + difference);
41
+        return sumByte;
42
+    }
43
+
44
+    /**
45
+     * @param baseValue  starting value
46
+     * @param difference value to add to starting value
47
+     * @return sum of `baseValue` and `difference`
48
+     */
49
+    public Float add(float baseValue, float difference) {
50
+        return baseValue + difference;
51
+    }
52
+
53
+    /**
54
+     * @param baseValue  starting value
55
+     * @param difference value to add to starting value
56
+     * @return sum of `baseValue` and `difference`
57
+     */
58
+    public Double add(double baseValue, double difference) {
59
+        return baseValue + difference;
60
+    }
61
+
62
+    /**
63
+     * @param baseValue  starting value
64
+     * @param difference value to subtract from starting value
65
+     * @return difference between `baseValue` and `difference`
66
+     */
67
+    public Integer subtract(int baseValue, int difference) {
68
+        return baseValue - difference;
69
+    }
70
+
71
+    /**
72
+     * @param baseValue  starting value
73
+     * @param difference value to subtract from starting value
74
+     * @return difference between `baseValue` and `difference`
75
+     */
76
+    public Long subtract(long baseValue, long difference) {
77
+        return baseValue - difference;
78
+    }
79
+
80
+    /**
81
+     * @param baseValue  starting value
82
+     * @param difference value to subtract from starting value
83
+     * @return difference between `baseValue` and `difference`
84
+     */
85
+    public Short subtract(short baseValue, short difference) {
86
+        short minusShort = (short) (baseValue - difference);
87
+        return minusShort;
88
+    }
89
+
90
+    /**
91
+     * @param baseValue  starting value
92
+     * @param difference value to subtract from starting value
93
+     * @return difference between `baseValue` and `difference`
94
+     */
95
+    public Byte subtract(byte baseValue, byte difference) {
96
+        byte minusByte = (byte) (baseValue - difference);
97
+        return minusByte;
98
+    }
99
+
100
+    /**
101
+     * @param baseValue  starting value
102
+     * @param difference value to subtract from starting value
103
+     * @return difference between `baseValue` and `difference`
104
+     */
105
+    public Float subtract(float baseValue, float difference) {
106
+        return (baseValue - difference);
107
+    }
108
+
109
+    /**
110
+     * @param baseValue  starting value
111
+     * @param difference value to subtract from starting value
112
+     * @return difference between `baseValue` and `difference`
113
+     */
114
+    public Double subtract(double baseValue, double difference) {
115
+        return (baseValue - difference);
116
+    }
117
+
118
+
119
+    /**
120
+     * @param dividend value to be divided
121
+     * @param divisor  value to divide by
122
+     * @return division of `dividend` by `divisor
123
+     */
124
+    public Integer divide(int dividend, int divisor) {
125
+        return (dividend / divisor);
126
+    }
127
+
128
+    /**
129
+     * @param dividend value to be divided
130
+     * @param divisor  value to divide by
131
+     * @return division of `dividend` by `divisor
132
+     */
133
+    public Long divide(long dividend, long divisor) {
134
+        return (dividend / divisor);
135
+    }
136
+
137
+    /**
138
+     * @param dividend value to be divided
139
+     * @param divisor  value to divide by
140
+     * @return division of `dividend` by `divisor
141
+     */
142
+    public Short divide(short dividend, short divisor) {
143
+        short divShort = (short) (dividend / divisor);
144
+        return divShort;
145
+    }
146
+
147
+    /**
148
+     * @param dividend value to be divided
149
+     * @param divisor  value to divide by
150
+     * @return division of `dividend` by `divisor
151
+     */
152
+    public Byte divide(byte dividend, byte divisor) {
153
+        byte divByte = (byte) (dividend / divisor);
154
+        return divByte;
155
+    }
156
+
157
+    /**
158
+     * @param dividend value to be divided
159
+     * @param divisor  value to divide by
160
+     * @return division of `dividend` by `divisor
161
+     */
162
+    public Float divide(float dividend, float divisor) {
163
+        return (dividend / divisor);
164
+    }
165
+
166
+    /**
167
+     * @param dividend value to be divided
168
+     * @param divisor  value to divide by
169
+     * @return division of `dividend` by `divisor
170
+     */
171
+    public Double divide(double dividend, double divisor) {
172
+        return (dividend / divisor);
173
+    }
174
+
175
+
176
+    /**
177
+     * @param multiplicand value to be multiplied
178
+     * @param multiplier   value to multiply by
179
+     * @return product of `multiplicand` by `multiplier`
180
+     */
181
+    public Integer multiply(int multiplicand, int multiplier) {
182
+        return (multiplicand * multiplier);
183
+    }
184
+
185
+    /**
186
+     * @param multiplicand value to be multiplied
187
+     * @param multiplier   value to multiply by
188
+     * @return product of `multiplicand` by `multiplier`
189
+     */
190
+    public Long multiply(long multiplicand, long multiplier) {
191
+        return (multiplicand * multiplier);
192
+    }
193
+
194
+    /**
195
+     * @param multiplicand value to be multiplied
196
+     * @param multiplier   value to multiply by
197
+     * @return product of `multiplicand` by `multiplier`
198
+     */
199
+    public Short multiply(short multiplicand, short multiplier) {
200
+        short multShort = (short) (multiplicand * multiplier);
201
+        return multShort;
202
+    }
203
+
204
+    /**
205
+     * @param multiplicand value to be multiplied
206
+     * @param multiplier   value to multiply by
207
+     * @return product of `multiplicand` by `multiplier`
208
+     */
209
+    public Byte multiply(byte multiplicand, byte multiplier) {
210
+        byte multByte = (byte) (multiplicand * multiplier);
211
+        return multByte;
212
+    }
213
+
214
+    /**
215
+     * @param multiplicand value to be multiplied
216
+     * @param multiplier   value to multiply by
217
+     * @return product of `multiplicand` by `multiplier`
218
+     */
219
+    public Float multiply(float multiplicand, float multiplier) {
220
+        return (multiplicand * multiplier);
221
+    }
222
+
223
+    /**
224
+     * @param multiplicand value to be multiplied
225
+     * @param multiplier   value to multiply by
226
+     * @return product of `multiplicand` by `multiplier`
227
+     */
228
+    public Double multiply(double multiplicand, double multiplier) {
229
+        return (multiplicand * multiplier);
230
+    }
231
+
232
+
233
+    /**
234
+     * @return true
235
+     */
236
+    public Boolean returnTrue() {
237
+        return true;
238
+    }
239
+
240
+    /**
241
+     * @return false
242
+     */
243
+    public Boolean returnFalse() {
244
+        return false;
245
+    }
246
+
247
+}

binární
Dan Do Better/PredicateUtilities.class Zobrazit soubor


+ 16
- 0
Dan Do Better/PredicateUtilities.ctxt Zobrazit soubor

@@ -0,0 +1,16 @@
1
+#BlueJ class context
2
+comment0.target=PredicateUtilities
3
+comment0.text=\n\ Created\ by\ dan\ on\ 6/14/17.\n
4
+comment1.params=x\ y
5
+comment1.target=java.lang.Boolean\ isGreaterThan(int,\ int)
6
+comment1.text=\n\ @param\ x\n\ @param\ y\n\ @return\ true\ if\ `x`\ is\ greater\ than\ `y`\n
7
+comment2.params=x\ y
8
+comment2.target=java.lang.Boolean\ isLessThan(int,\ int)
9
+comment2.text=\n\ @param\ x\n\ @param\ y\n\ @return\ true\ if\ `x`\ is\ less\ than\ `y`\n
10
+comment3.params=x\ y
11
+comment3.target=java.lang.Boolean\ isGreaterThanOrEqualTo(int,\ int)
12
+comment3.text=\n\ @param\ x\n\ @param\ y\n\ @return\ true\ if\ `x`\ is\ greater\ than\ or\ equal\ to\ `y`\n
13
+comment4.params=x\ y
14
+comment4.target=java.lang.Boolean\ isLessThanOrEqualTo(int,\ int)
15
+comment4.text=\n\ @param\ x\n\ @param\ y\n\ @return\ true\ if\ `x`\ is\ less\ than\ or\ equal\ to\ `y`\n
16
+numComments=5

+ 69
- 0
Dan Do Better/PredicateUtilities.java Zobrazit soubor

@@ -0,0 +1,69 @@
1
+
2
+/**
3
+ * Created by dan on 6/14/17.
4
+ */
5
+public class PredicateUtilities {
6
+    /**
7
+     * @param x
8
+     * @param y
9
+     * @return true if `x` is greater than `y`
10
+     */
11
+    public Boolean isGreaterThan(int x, int y) {
12
+        boolean z;
13
+
14
+        if (x > y) {
15
+            z = true;
16
+        } else {
17
+            z = false;
18
+        }
19
+        return z;
20
+    }
21
+
22
+    /**
23
+     * @param x
24
+     * @param y
25
+     * @return true if `x` is less than `y`
26
+     */
27
+    public Boolean isLessThan(int x, int y) {
28
+        boolean z;
29
+
30
+        if (x < y) {
31
+            z = true;
32
+        } else {
33
+            z = false;
34
+        }
35
+        return z;
36
+    }
37
+
38
+    /**
39
+     * @param x
40
+     * @param y
41
+     * @return true if `x` is greater than or equal to `y`
42
+     */
43
+    public Boolean isGreaterThanOrEqualTo(int x, int y) {
44
+        boolean z;
45
+
46
+        if (x >= y) {
47
+            z = true;
48
+        } else {
49
+            z = false;
50
+        }
51
+        return z;
52
+    }
53
+
54
+    /**
55
+     * @param x
56
+     * @param y
57
+     * @return true if `x` is less than or equal to `y`
58
+     */
59
+    public Boolean isLessThanOrEqualTo(int x, int y) {
60
+        boolean z;
61
+
62
+        if (x <= y) {
63
+            z = true;
64
+        } else {
65
+            z = false;
66
+        }
67
+        return z;
68
+    }
69
+}

+ 12
- 0
Dan Do Better/README.TXT Zobrazit soubor

@@ -0,0 +1,12 @@
1
+------------------------------------------------------------------------
2
+This is the project README file. Here, you should describe your project.
3
+Tell the reader (someone who does not know anything about this project)
4
+all he/she needs to know. The comments should usually include at least:
5
+------------------------------------------------------------------------
6
+
7
+PROJECT TITLE:
8
+PURPOSE OF PROJECT:
9
+VERSION or DATE:
10
+HOW TO START THIS PROJECT:
11
+AUTHORS:
12
+USER INSTRUCTIONS:

binární
Dan Do Better/StringUtilities.class Zobrazit soubor


+ 34
- 0
Dan Do Better/StringUtilities.ctxt Zobrazit soubor

@@ -0,0 +1,34 @@
1
+#BlueJ class context
2
+comment0.target=StringUtilities
3
+comment0.text=\n\ Created\ by\ dan\ on\ 6/14/17.\n
4
+comment1.params=
5
+comment1.target=java.lang.String\ getHelloWorld()
6
+comment1.text=\n\ @return\ `Hello\ World`\ as\ a\ string\n
7
+comment10.params=stringToReverse
8
+comment10.target=java.lang.String\ reverse(java.lang.String)
9
+comment10.text=\n\ @param\ stringToReverse\n\ @return\ an\ identical\ string\ with\ characters\ in\ reverse\ order.\n
10
+comment2.params=firstSegment\ secondSegment
11
+comment2.target=java.lang.String\ concatenation(java.lang.String,\ java.lang.String)
12
+comment2.text=\n\ @param\ firstSegment\ a\ string\ to\ be\ added\ to\n\ @param\ secondSegment\ a\ string\ to\ add\n\ @return\ the\ concatenation\ of\ two\ strings,\ `firstSegment`,\ and\ `secondSegment`\n
13
+comment3.params=firstSegment\ secondSegment
14
+comment3.target=java.lang.String\ concatenation(int,\ java.lang.String)
15
+comment3.text=\n\ @param\ firstSegment\ a\ string\ to\ be\ added\ to\n\ @param\ secondSegment\ a\ string\ to\ add\n\ @return\ the\ concatenation\ of\ an\ integer,\ `firstSegment`,\ and\ a\ String,\ `secondSegment`\n
16
+comment4.params=input
17
+comment4.target=java.lang.String\ getPrefix(java.lang.String)
18
+comment4.text=\n\ @param\ input\ a\ string\ to\ be\ manipulated\n\ @return\ the\ first\ 3\ characters\ of\ `input`\n
19
+comment5.params=input
20
+comment5.target=java.lang.String\ getSuffix(java.lang.String)
21
+comment5.text=\n\ @param\ input\ a\ string\ to\ be\ manipulated\n\ @return\ the\ last\ 3\ characters\ of\ `input`\n
22
+comment6.params=inputValue\ comparableValue
23
+comment6.target=java.lang.Boolean\ compareTwoStrings(java.lang.String,\ java.lang.String)
24
+comment6.text=\n\ @param\ inputValue\ the\ value\ to\ be\ compared\n\ @param\ comparableValue\ the\ value\ to\ be\ compared\ against\n\ @return\ the\ equivalence\ of\ two\ strings,\ `inputValue`\ and\ `comparableValue`\n
25
+comment7.params=inputValue
26
+comment7.target=java.lang.Character\ getMiddleCharacter(java.lang.String)
27
+comment7.text=\n\ @param\ inputValue\ the\ value\ input\ from\ user\n\ @return\ the\ middle\ character\ of\ `inputValue`\n
28
+comment8.params=spaceDelimitedString
29
+comment8.target=java.lang.String\ getFirstWord(java.lang.String)
30
+comment8.text=\n\ @param\ spaceDelimitedString\ a\ string,\ representative\ of\ a\ sentence,\ containing\ spaces\n\ @return\ the\ first\ sequence\ of\ characters\n
31
+comment9.params=spaceDelimitedString
32
+comment9.target=java.lang.String\ getSecondWord(java.lang.String)
33
+comment9.text=\n\ @param\ spaceDelimitedString\ a\ string\ delimited\ by\ spaces\n\ @return\ the\ second\ word\ of\ a\ string\ delimited\ by\ spaces.\n
34
+numComments=11

+ 114
- 0
Dan Do Better/StringUtilities.java Zobrazit soubor

@@ -0,0 +1,114 @@
1
+/**
2
+ * Created by dan on 6/14/17.
3
+ */
4
+public class StringUtilities {
5
+    /**
6
+     * @return `Hello World` as a string
7
+     */
8
+    public static String getHelloWorld() {
9
+        String hello = "Hello World";
10
+        return hello;
11
+    }
12
+
13
+    /**
14
+     * @param firstSegment a string to be added to
15
+     * @param secondSegment a string to add
16
+     * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
17
+     */
18
+    public static String concatenation(String firstSegment, String secondSegment){
19
+        String conCat = firstSegment.concat(secondSegment);
20
+        return conCat;
21
+    }
22
+
23
+    /**
24
+     * @param firstSegment a string to be added to
25
+     * @param secondSegment a string to add
26
+     * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27
+     */
28
+    public static String concatenation(int firstSegment, String secondSegment){
29
+        String conCat2 = (firstSegment + secondSegment);
30
+        return conCat2;
31
+    }
32
+
33
+    /**
34
+     * @param input a string to be manipulated
35
+     * @return the first 3 characters of `input`
36
+     */
37
+    public static String getPrefix(String input){
38
+        String firstThree = input.substring(0, 3);        
39
+        return firstThree;
40
+    }
41
+
42
+    /**
43
+     * @param input a string to be manipulated
44
+     * @return the last 3 characters of `input`
45
+     */
46
+    public static String getSuffix(String input){
47
+        String lastThree = input.substring((input.length() - 3), (input.length()));
48
+        return lastThree;
49
+    }
50
+
51
+    /**
52
+     * @param inputValue the value to be compared
53
+     * @param comparableValue the value to be compared against
54
+     * @return the equivalence of two strings, `inputValue` and `comparableValue`
55
+     */
56
+    public static Boolean compareTwoStrings(String inputValue, String comparableValue){
57
+        boolean stringEqual = inputValue.equalsIgnoreCase(comparableValue);        
58
+        return stringEqual;
59
+    }
60
+
61
+    /**
62
+     * @param inputValue the value input from user
63
+     * @return the middle character of `inputValue`
64
+     */
65
+    public static Character getMiddleCharacter(String inputValue){
66
+        int midCharLocation = (inputValue.length() - 1) / 2;  // gets index #
67
+        char midChar = inputValue.charAt(midCharLocation);
68
+        return midChar;
69
+    }
70
+
71
+    /**
72
+     * @param spaceDelimitedString a string, representative of a sentence, containing spaces
73
+     * @return the first sequence of characters
74
+     */
75
+    public static String getFirstWord(String spaceDelimitedString){
76
+        int firstSpace = spaceDelimitedString.indexOf(" ");
77
+        String firstWord = spaceDelimitedString.substring(0, firstSpace);        
78
+        return firstWord;
79
+    }
80
+
81
+    /**
82
+     * @param spaceDelimitedString a string delimited by spaces
83
+     * @return the second word of a string delimited by spaces.
84
+     */
85
+    public static String getSecondWord(String spaceDelimitedString){
86
+        // find index of first space
87
+        int firstSpace = spaceDelimitedString.indexOf(" ");
88
+        // find index of second space
89
+        int secondSpace = spaceDelimitedString.indexOf(" ", firstSpace + 1);
90
+
91
+        String secondWord;
92
+        
93
+        if (secondSpace > 0) {
94
+            secondWord = spaceDelimitedString.substring(firstSpace, secondSpace);
95
+        } else {
96
+            secondWord = spaceDelimitedString.substring((firstSpace + 1),(spaceDelimitedString.length()));
97
+        }
98
+
99
+        return secondWord;
100
+    }
101
+
102
+    /**
103
+     * @param stringToReverse
104
+     * @return an identical string with characters in reverse order.
105
+     */
106
+    public static String reverse(String stringToReverse){
107
+        // change string in stringbuilder
108
+        StringBuilder reverseSB = new StringBuilder(stringToReverse);
109
+        // use built-in stringbuilder reverse method and then change back to string
110
+        String reverse = reverseSB.reverse().toString();
111
+        
112
+        return reverse;
113
+    }
114
+}

binární
Dan Do Better/TestMathUtilities.class Zobrazit soubor


+ 56
- 0
Dan Do Better/TestMathUtilities.ctxt Zobrazit soubor

@@ -0,0 +1,56 @@
1
+#BlueJ class context
2
+comment0.target=TestMathUtilities
3
+comment0.text=\n\ Created\ by\ dan\ on\ 6/14/17.\n
4
+comment1.params=
5
+comment1.target=void\ testAdditions()
6
+comment10.params=
7
+comment10.target=void\ testSubtractions3()
8
+comment11.params=
9
+comment11.target=void\ testSubtractions4()
10
+comment12.params=
11
+comment12.target=void\ testSubtractions5()
12
+comment13.params=
13
+comment13.target=void\ testDivision()
14
+comment14.params=
15
+comment14.target=void\ testDivision1()
16
+comment15.params=
17
+comment15.target=void\ testDivision2()
18
+comment16.params=
19
+comment16.target=void\ testDivision3()
20
+comment17.params=
21
+comment17.target=void\ testDivision4()
22
+comment18.params=
23
+comment18.target=void\ testDivision5()
24
+comment19.params=
25
+comment19.target=void\ testMultiplication()
26
+comment2.params=
27
+comment2.target=void\ testAdditions1()
28
+comment20.params=
29
+comment20.target=void\ testMultiplication1()
30
+comment21.params=
31
+comment21.target=void\ testMultiplication2()
32
+comment22.params=
33
+comment22.target=void\ testMultiplication3()
34
+comment23.params=
35
+comment23.target=void\ testMultiplication4()
36
+comment24.params=
37
+comment24.target=void\ testMultiplication5()
38
+comment25.params=
39
+comment25.target=void\ testReturnTrue()
40
+comment26.params=
41
+comment26.target=void\ testReturnFalse()
42
+comment3.params=
43
+comment3.target=void\ testAdditions2()
44
+comment4.params=
45
+comment4.target=void\ testAdditions4()
46
+comment5.params=
47
+comment5.target=void\ testAdditions5()
48
+comment6.params=
49
+comment6.target=void\ testAdditions6()
50
+comment7.params=
51
+comment7.target=void\ testSubtractions()
52
+comment8.params=
53
+comment8.target=void\ testSubtractions1()
54
+comment9.params=
55
+comment9.target=void\ testSubtractions2()
56
+numComments=27

+ 342
- 0
Dan Do Better/TestMathUtilities.java Zobrazit soubor

@@ -0,0 +1,342 @@
1
+import org.junit.Test;
2
+
3
+import static org.junit.Assert.*;
4
+/**
5
+ * Created by dan on 6/14/17.
6
+ */
7
+public class TestMathUtilities {
8
+    private static volatile MathUtilities primativeTypes = new MathUtilities();
9
+
10
+    @Test
11
+    public void testAdditions() {
12
+        // : Given
13
+        int baseValue = 20;
14
+        int addedValue = 7;
15
+        int expected = 27;
16
+        // : When
17
+        int actual = primativeTypes.add(baseValue, addedValue);
18
+        // : Then
19
+        assertEquals(expected,actual);
20
+    }
21
+    @Test
22
+    public void testAdditions1() {
23
+        // : Given
24
+        long baseValue = 228437266;
25
+        long difference = 228437265;
26
+        long expected = 456874531;
27
+        // : When
28
+        long actual = primativeTypes.add(baseValue, difference);
29
+        // : Then
30
+        assertEquals(expected,actual);
31
+    }
32
+    @Test
33
+    public void testAdditions2() {
34
+        // : Given
35
+        short baseValue = 16384;
36
+        short addedValue = 7;
37
+        short expected = 16391;
38
+        // : When
39
+        short actual = primativeTypes.add(baseValue, addedValue);
40
+        // : Then
41
+        assertEquals(expected,actual);
42
+    }
43
+
44
+    @Test
45
+    public void testAdditions4() {
46
+        // : Given
47
+        byte baseValue = 63;
48
+        byte addedValue = 64;
49
+        byte expected = 127;
50
+        // : When
51
+        byte actual = primativeTypes.add(baseValue, addedValue);
52
+        // : Then
53
+        assertEquals(expected,actual);
54
+    }
55
+    @Test
56
+    public void testAdditions5() {
57
+        // : Given
58
+        float baseValue = 750.585F;
59
+        float addedValue = 795.000F;
60
+        float expected = 1545.585F;
61
+        // : When
62
+        float actual = primativeTypes.add(baseValue, addedValue);
63
+        // : Then
64
+        assertEquals(expected,actual, 0);
65
+    }
66
+
67
+    @Test
68
+    public void testAdditions6() {
69
+        // : Given
70
+        double baseValue = 225.25;
71
+        double addedValue = 231;
72
+        double expected = 456.25;
73
+        // : When
74
+        double actual = primativeTypes.add(baseValue,addedValue);
75
+        // : Then
76
+        assertEquals(expected,actual, 0);
77
+    }
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+    @Test
95
+    public void testSubtractions(){
96
+        // : Given
97
+        int baseValue = 20;
98
+        int difference = 7;
99
+        int expectedInt = 13;
100
+        // : When
101
+        int actualInt = primativeTypes.subtract(baseValue,difference);
102
+        // : Then
103
+        assertEquals(expectedInt,actualInt);
104
+    }
105
+    @Test
106
+    public void testSubtractions1() {
107
+        // : Given
108
+        long baseValue = 228437266;
109
+        long difference = 228437265;
110
+        long expectedLong = 1;
111
+        // : When
112
+        long actualLong = primativeTypes.subtract(baseValue, difference);
113
+        // : Then
114
+        assertEquals(expectedLong,actualLong);
115
+    }
116
+    @Test
117
+    public void testSubtractions2() {
118
+        // : Given
119
+        short baseValue = 16384;
120
+        short difference = 16383;
121
+        short expectedShort = 1;
122
+        // : When
123
+        short actualShort = primativeTypes.subtract(baseValue, difference);
124
+        // : Then
125
+        assertEquals(expectedShort,actualShort);
126
+    }
127
+    @Test
128
+    public void testSubtractions3() {
129
+        // : Given
130
+        byte baseValue = 63;
131
+        byte difference = 64;
132
+        byte expectedByte = -1;
133
+        // : When
134
+        byte actualByte = primativeTypes.subtract(baseValue, difference);
135
+        // : Then
136
+        assertEquals(expectedByte,actualByte);
137
+    }
138
+    @Test
139
+    public void testSubtractions4() {
140
+        // : Given
141
+        float baseValue = 750.585F;
142
+        float difference = 795.0F;
143
+        float expectedFloat = -44.415F;
144
+        // : When
145
+        float actualFloat = primativeTypes.subtract(baseValue,difference);
146
+        // : Then
147
+        assertEquals(expectedFloat,actualFloat, 0.005);
148
+    }
149
+    @Test
150
+    public void testSubtractions5() {
151
+        // : Given
152
+        double baseValue = 225.25;
153
+        double difference = 231;
154
+        double expectedDouble = -5.75;
155
+        // : When
156
+        double actualDouble = primativeTypes.subtract(baseValue, difference);
157
+        // : Then
158
+        assertEquals(expectedDouble,actualDouble, 0);
159
+    }
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+    @Test
175
+    public void testDivision(){
176
+        // : Given
177
+        int dividend = 20;
178
+        int divisor = 2;
179
+        int expectedInt = 10;
180
+        // : When
181
+        int actualInt = primativeTypes.divide(dividend, divisor);
182
+        // : Then
183
+        assertEquals(expectedInt,actualInt);
184
+    }
185
+    @Test
186
+    public void testDivision1() {
187
+        // : Given
188
+        int dividend = 20000000;
189
+        int divisor = 1000;
190
+        long expectedLong = 20000;
191
+        // : When
192
+        long actualLong = primativeTypes.divide(dividend, divisor);
193
+        // : Then
194
+        assertEquals(expectedLong,actualLong);
195
+    }
196
+    @Test
197
+    public void testDivision2() {
198
+        // : Given
199
+        short dividend = 2;
200
+        short divisor = 1;
201
+        short expectedShort = 2;
202
+        // : When
203
+        short actualShort = primativeTypes.divide(dividend, divisor);
204
+        // : Then
205
+        assertEquals(expectedShort,actualShort);
206
+
207
+    }
208
+    @Test
209
+    public void testDivision3() {
210
+        // : Given
211
+        byte dividend = 64;
212
+        byte divisor = 32;
213
+        byte expectedByte = 2;
214
+        // : When
215
+        byte actualByte = primativeTypes.divide(dividend, divisor);
216
+        // : Then
217
+        assertEquals(expectedByte,actualByte);
218
+    }
219
+    @Test
220
+    public void testDivision4() {
221
+        // : Given
222
+        float dividend = 7.5F;
223
+        float divisor = 3;
224
+        float expectedFloat = 2.50F;
225
+        // : When
226
+        float actualFloat = primativeTypes.divide(dividend,divisor);
227
+        // : Then
228
+        assertEquals(expectedFloat,actualFloat, 0);
229
+    }
230
+    @Test
231
+    public void testDivision5() {
232
+        // : Given
233
+        double dividend = 5.0;
234
+        double divisor = 4.0;
235
+        double expectedDouble = 1.25;
236
+        // : When
237
+        double actualDouble = primativeTypes.divide(dividend,divisor);
238
+        // : Then
239
+        assertEquals(expectedDouble,actualDouble, 0);
240
+    }
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+    @Test
260
+    public void testMultiplication(){
261
+        // : Given
262
+        int multiplicand = 5;
263
+        int multiplier = 2;
264
+        int expectedInt = 10;
265
+        // : When
266
+        int actualInt = primativeTypes.multiply(multiplicand,multiplier);
267
+        // : Then
268
+        assertEquals(expectedInt,actualInt);
269
+    }
270
+    @Test
271
+    public void testMultiplication1() {
272
+        // : Given
273
+        long multiplicand = 20;
274
+        long multiplier = 1000;
275
+        long expectedLong = 20000;
276
+        // : When
277
+        long actualLong = primativeTypes.multiply(multiplicand, multiplier);
278
+        // : Then
279
+        assertEquals(expectedLong, actualLong);
280
+    }
281
+    @Test
282
+    public void testMultiplication2() {
283
+        // : Given
284
+        short multiplicand = 2;
285
+        short multiplier = 1;
286
+        short expectedShort = 2;
287
+        // : When
288
+        short actualShort = primativeTypes.multiply(multiplicand, multiplier);
289
+        // : Then
290
+        assertEquals(expectedShort, actualShort);
291
+    }
292
+    @Test
293
+    public void testMultiplication3() {
294
+        // : Given
295
+        byte multiplicand = 16;
296
+        byte multiplier = 4;
297
+        byte expectedByte = 64;
298
+        // : When
299
+        byte actualByte = primativeTypes.multiply(multiplicand, multiplier);
300
+        // : Then
301
+        assertEquals(expectedByte, actualByte);
302
+    }
303
+    @Test
304
+    public void testMultiplication4() {
305
+        // : Given
306
+        float multiplicand = 2.5F;
307
+        float multiplier = 1;
308
+        float expectedFloat = 2.50F;
309
+        // : When
310
+        float actualFloat =  primativeTypes.multiply(multiplicand,multiplier);
311
+        // : Then
312
+        assertEquals(expectedFloat, actualFloat, 0);
313
+    }
314
+    @Test
315
+    public void testMultiplication5() {
316
+        // : Given
317
+        double multiplicand = 3.25;
318
+        double multiplier = 3.0;
319
+        double expectedDouble = 9.75;
320
+        // : When
321
+        double actualDouble = primativeTypes.multiply(multiplicand,multiplier);
322
+        // : Then
323
+        assertEquals(expectedDouble, actualDouble, 0);
324
+    }
325
+
326
+    @Test
327
+    public void testReturnTrue(){
328
+        // : Given
329
+        // : When
330
+        // : Then
331
+        assertTrue(primativeTypes.returnTrue());
332
+    }
333
+
334
+    @Test
335
+    public void testReturnFalse(){
336
+        // : Given
337
+        // : When
338
+        // : Then
339
+        assertFalse(primativeTypes.returnFalse());
340
+    }
341
+
342
+}

binární
Dan Do Better/TestPredicateUtilities.class Zobrazit soubor


+ 20
- 0
Dan Do Better/TestPredicateUtilities.ctxt Zobrazit soubor

@@ -0,0 +1,20 @@
1
+#BlueJ class context
2
+comment0.target=TestPredicateUtilities
3
+comment0.text=\n\ Created\ by\ dan\ on\ 6/14/17.\n
4
+comment1.params=
5
+comment1.target=void\ testGreaterThanTrue()
6
+comment2.params=
7
+comment2.target=void\ testGreaterThanFalse()
8
+comment3.params=
9
+comment3.target=void\ testLessThanTrue()
10
+comment4.params=
11
+comment4.target=void\ testLessThan1()
12
+comment5.params=
13
+comment5.target=void\ testLessOrEqual1()
14
+comment6.params=
15
+comment6.target=void\ testLessOrEqual2()
16
+comment7.params=
17
+comment7.target=void\ testGreaterOrEqual1()
18
+comment8.params=
19
+comment8.target=void\ testGreaterOrEqual2()
20
+numComments=9

+ 120
- 0
Dan Do Better/TestPredicateUtilities.java Zobrazit soubor

@@ -0,0 +1,120 @@
1
+import org.junit.Test;
2
+
3
+import static org.junit.Assert.*;
4
+
5
+/**
6
+ * Created by dan on 6/14/17.
7
+ */
8
+public class TestPredicateUtilities {
9
+    private static volatile PredicateUtilities math = new PredicateUtilities();
10
+
11
+    @Test
12
+    public void testGreaterThanTrue() {
13
+        // : Given
14
+        int greaterValue = 450;
15
+        int lesserValue = 350;
16
+
17
+
18
+        // : When
19
+        boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
20
+
21
+        // : Then
22
+        assertTrue(outcome);
23
+    }
24
+
25
+
26
+    @Test
27
+    public void testGreaterThanFalse() {
28
+        // : Given
29
+        int greaterValue = 350;
30
+        int lesserValue = 350;
31
+
32
+        // : When
33
+        boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
34
+
35
+        // : Then
36
+        assertFalse(outcome);
37
+    }
38
+
39
+
40
+    @Test
41
+    public void testLessThanTrue() {
42
+        // : Given
43
+        int greaterValue = 450;
44
+        int lesserValue = 350;
45
+
46
+        // : When
47
+        boolean outcome = math.isLessThan(greaterValue, lesserValue);
48
+
49
+        // : Then
50
+        assertFalse(outcome);
51
+    }
52
+
53
+
54
+    @Test
55
+    public void testLessThan1() {
56
+        // : Given
57
+        int greaterValue = 450;
58
+        int lesserValue = 350;
59
+
60
+        // : When
61
+        boolean outcome = math.isLessThan(greaterValue, lesserValue);
62
+
63
+        // : Then
64
+        assertFalse(outcome);
65
+    }
66
+
67
+
68
+    @Test
69
+    public void testLessOrEqual1() {
70
+        // : Given
71
+        int greaterValue = 3;
72
+        int lesserValue = 3;
73
+
74
+        // : When
75
+        boolean outcome = math.isLessThanOrEqualTo(greaterValue, lesserValue);
76
+
77
+        // : Then
78
+        assertTrue(outcome);
79
+    }
80
+
81
+    @Test
82
+    public void testLessOrEqual2() {
83
+        // : Given
84
+        int greaterValue = 3;
85
+        int lesserValue = 6;
86
+
87
+        // : When
88
+        boolean outcome = math.isLessThanOrEqualTo(greaterValue, lesserValue);
89
+
90
+        // : Then
91
+        assertTrue(outcome);
92
+    }
93
+
94
+    @Test
95
+    public void testGreaterOrEqual1() {
96
+        // : Given
97
+        int greaterValue = 4;
98
+        int lesserValue = 4;
99
+
100
+        // : When
101
+        boolean outcome = math.isGreaterThanOrEqualTo(greaterValue, lesserValue);
102
+
103
+        // : ThenP
104
+        assertTrue(outcome);
105
+    }
106
+
107
+
108
+    @Test
109
+    public void testGreaterOrEqual2() {
110
+        // : Given
111
+        int greaterValue = 8;
112
+        int lesserValue = 15;
113
+
114
+        // : When
115
+        boolean outcome = math.isGreaterThanOrEqualTo(greaterValue, lesserValue);
116
+
117
+        // : Then
118
+        assertFalse(outcome);
119
+    }
120
+}

binární
Dan Do Better/TestStringUtilities.class Zobrazit soubor


+ 28
- 0
Dan Do Better/TestStringUtilities.ctxt Zobrazit soubor

@@ -0,0 +1,28 @@
1
+#BlueJ class context
2
+comment0.target=TestStringUtilities
3
+comment0.text=\n\ Created\ by\ dan\ on\ 6/14/17.\n
4
+comment1.params=
5
+comment1.target=void\ getHelloWorldTest()
6
+comment10.params=
7
+comment10.target=void\ getTheFirstWord()
8
+comment11.params=
9
+comment11.target=void\ getTheSecondWord()
10
+comment12.params=
11
+comment12.target=void\ reverseThem()
12
+comment2.params=
13
+comment2.target=void\ concatenationStringTest()
14
+comment3.params=
15
+comment3.target=void\ concatenationStringAndIntegerTest()
16
+comment4.params=
17
+comment4.target=void\ substringBeginTest()
18
+comment5.params=
19
+comment5.target=void\ substringEndTest()
20
+comment6.params=
21
+comment6.target=void\ compareToTestEquals()
22
+comment7.params=
23
+comment7.target=void\ compareToTestNotEquals()
24
+comment8.params=
25
+comment8.target=void\ getTheMiddleChar1()
26
+comment9.params=
27
+comment9.target=void\ getTheMiddleChar2()
28
+numComments=13

+ 174
- 0
Dan Do Better/TestStringUtilities.java Zobrazit soubor

@@ -0,0 +1,174 @@
1
+import org.junit.Assert;
2
+import org.junit.Test;
3
+import static org.junit.Assert.*;
4
+
5
+/**
6
+ * Created by dan on 6/14/17.
7
+ */
8
+public class TestStringUtilities {
9
+    @Test
10
+    public void getHelloWorldTest() {
11
+        // : Given
12
+        String expected = "Hello World";
13
+
14
+        // : When
15
+        String actual = StringUtilities.getHelloWorld();
16
+
17
+        // : Then
18
+        assertEquals(expected, actual);
19
+
20
+    }
21
+
22
+    @Test
23
+    public void concatenationStringTest(){
24
+        // : Given
25
+        String one = "Hello";
26
+        String two = " Java";
27
+        String expected = "Hello Java";
28
+
29
+        // : When
30
+        String actual = StringUtilities.concatenation(one,two);
31
+
32
+
33
+        // : Then
34
+        assertEquals(expected, actual);
35
+    }
36
+
37
+
38
+    @Test
39
+    public void concatenationStringAndIntegerTest(){
40
+        // : Given
41
+        int one = 1;
42
+        String two = " Java";
43
+        String expected = "1 Java";
44
+
45
+        // : When
46
+        String actual = StringUtilities.concatenation(one,two);
47
+
48
+
49
+        // : Then
50
+        assertEquals(expected, actual);
51
+    }
52
+
53
+    @Test
54
+    public void substringBeginTest(){
55
+        // : Given
56
+        String input = "Hello";
57
+        String expected = "Hel";
58
+
59
+        // : When
60
+        String actual = StringUtilities.getPrefix(input);
61
+
62
+        // : Then
63
+        assertEquals(expected, actual);
64
+    }
65
+
66
+    @Test
67
+    public void substringEndTest(){
68
+        // : Given
69
+        String input = "Hello";
70
+        String expected = "llo";
71
+
72
+        // : When
73
+        String actual = StringUtilities.getSuffix("Hello");
74
+
75
+        // : Then
76
+        assertEquals(expected, actual);
77
+    }
78
+
79
+    @Test
80
+    public void compareToTestEquals(){
81
+        // : Given
82
+        String inputValue = "Zipcode";
83
+        String comparableValue = "Zipcode";
84
+
85
+        // : When
86
+        boolean actual = StringUtilities.compareTwoStrings(inputValue, comparableValue);
87
+
88
+        // : Then
89
+        assertTrue(actual);
90
+    }
91
+
92
+
93
+    @Test
94
+    public void compareToTestNotEquals(){
95
+        // : Given
96
+        String inputValue = "Zipcode";
97
+        String comparableValue = "Zipcodee";
98
+
99
+        // : When
100
+        boolean actual = StringUtilities.compareTwoStrings(inputValue, comparableValue);
101
+
102
+        // : Then
103
+        assertFalse(actual);
104
+    }
105
+
106
+    @Test
107
+    public void getTheMiddleChar1(){
108
+        // : Given
109
+        String input = "Zipcode";
110
+        Character expected = 'c';
111
+
112
+        // : When
113
+        Character actual = StringUtilities.getMiddleCharacter(input);
114
+
115
+        // : Then
116
+        Assert.assertEquals(expected.toString(), actual.toString());
117
+    }
118
+
119
+
120
+    @Test
121
+    public void getTheMiddleChar2(){
122
+        // : Given
123
+        String input = "Zipcoder";
124
+        Character expected = 'c';
125
+
126
+        // : When
127
+        Character actual = StringUtilities.getMiddleCharacter(input);
128
+
129
+        // : Then
130
+        Assert.assertEquals(expected.toString(), actual.toString());
131
+    }
132
+
133
+
134
+    @Test
135
+    public void getTheFirstWord(){
136
+        // : Given
137
+        String input = "Zipcode Wilmington";
138
+        String expected = "Zipcode";
139
+
140
+        // : When
141
+        String actual = StringUtilities.getFirstWord(input);
142
+
143
+        // : Then
144
+        assertEquals(expected, actual);
145
+    }
146
+
147
+
148
+    @Test
149
+    public void getTheSecondWord(){
150
+        // : Given
151
+        String input = "Zipcode Wilmington";
152
+        String expected = "Wilmington";
153
+
154
+        // : When
155
+        String actual = StringUtilities.getSecondWord(input);
156
+
157
+        // : Then
158
+        assertEquals(expected, actual);
159
+    }
160
+
161
+    @Test
162
+    public void reverseThem(){
163
+        // : Given
164
+        String input = "Zipcode Wilmington";
165
+        String expected = "notgnimliW edocpiZ";
166
+
167
+
168
+        // : When
169
+        String actual = StringUtilities.reverse(input);
170
+
171
+        // : Then
172
+        assertEquals(expected, actual);
173
+    }
174
+}

binární
Dan Do Better/ZipcodeRocks.class Zobrazit soubor


+ 6
- 0
Dan Do Better/ZipcodeRocks.ctxt Zobrazit soubor

@@ -0,0 +1,6 @@
1
+#BlueJ class context
2
+comment0.target=ZipcodeRocks
3
+comment0.text=\n\ Created\ by\ leon\ on\ 2/5/18.\n
4
+comment1.params=args
5
+comment1.target=void\ main(java.lang.String[])
6
+numComments=2

+ 8
- 0
Dan Do Better/ZipcodeRocks.java Zobrazit soubor

@@ -0,0 +1,8 @@
1
+ /**
2
+ * Created by leon on 2/5/18.
3
+ */
4
+public class ZipcodeRocks {
5
+    public static void main(String[] args) {
6
+         System.out.println("Zipcode Rocks!");
7
+    }
8
+}

+ 86
- 0
Dan Do Better/package.bluej Zobrazit soubor

@@ -0,0 +1,86 @@
1
+#BlueJ package file
2
+dependency1.from=TestMathUtilities
3
+dependency1.to=MathUtilities
4
+dependency1.type=UsesDependency
5
+dependency2.from=TestPredicateUtilities
6
+dependency2.to=PredicateUtilities
7
+dependency2.type=UsesDependency
8
+dependency3.from=TestStringUtilities
9
+dependency3.to=StringUtilities
10
+dependency3.type=UsesDependency
11
+editor.fx.0.height=722
12
+editor.fx.0.width=800
13
+editor.fx.0.x=998
14
+editor.fx.0.y=177
15
+objectbench.height=101
16
+objectbench.width=776
17
+package.divider.horizontal=0.6
18
+package.divider.vertical=0.8007380073800738
19
+package.editor.height=427
20
+package.editor.width=674
21
+package.editor.x=1080
22
+package.editor.y=216
23
+package.frame.height=600
24
+package.frame.width=800
25
+package.numDependencies=3
26
+package.numTargets=7
27
+package.showExtends=true
28
+package.showUses=true
29
+project.charset=UTF-8
30
+readme.height=58
31
+readme.name=@README
32
+readme.width=47
33
+readme.x=10
34
+readme.y=10
35
+target1.association=TestPredicateUtilities
36
+target1.height=50
37
+target1.name=PredicateUtilities
38
+target1.showInterface=false
39
+target1.type=ClassTarget
40
+target1.width=130
41
+target1.x=310
42
+target1.y=90
43
+target2.height=50
44
+target2.name=TestPredicateUtilities
45
+target2.showInterface=false
46
+target2.type=UnitTestTargetJunit4
47
+target2.width=160
48
+target2.x=340
49
+target2.y=60
50
+target3.height=50
51
+target3.name=TestMathUtilities
52
+target3.showInterface=false
53
+target3.type=UnitTestTargetJunit4
54
+target3.width=100
55
+target3.x=120
56
+target3.y=60
57
+target4.height=50
58
+target4.name=TestStringUtilities
59
+target4.showInterface=false
60
+target4.type=UnitTestTargetJunit4
61
+target4.width=110
62
+target4.x=390
63
+target4.y=190
64
+target5.association=TestMathUtilities
65
+target5.height=50
66
+target5.name=MathUtilities
67
+target5.showInterface=false
68
+target5.type=ClassTarget
69
+target5.width=100
70
+target5.x=90
71
+target5.y=90
72
+target6.association=TestStringUtilities
73
+target6.height=50
74
+target6.name=StringUtilities
75
+target6.showInterface=false
76
+target6.type=ClassTarget
77
+target6.width=110
78
+target6.x=360
79
+target6.y=220
80
+target7.height=50
81
+target7.name=ZipcodeRocks
82
+target7.showInterface=false
83
+target7.type=ClassTarget
84
+target7.width=110
85
+target7.x=130
86
+target7.y=220

+ 48
- 41
src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java Zobrazit soubor

@@ -1,5 +1,3 @@
1
-package com.zipcodewilmington.danny_do_better_exercises;
2
-
3 1
 /**
4 2
  * Created by dan on 6/14/17.
5 3
  */
@@ -11,7 +9,7 @@ public class MathUtilities {
11 9
      * @return sum of `baseValue` and `difference`
12 10
      */
13 11
     public Integer add(int baseValue, int difference) {
14
-        return null;
12
+        return (baseValue + difference);
15 13
     }
16 14
 
17 15
     /**
@@ -20,7 +18,7 @@ public class MathUtilities {
20 18
      * @return sum of `baseValue` and `difference`
21 19
      */
22 20
     public Long add(long baseValue, long difference) {
23
-        return null;
21
+        return baseValue + difference;
24 22
     }
25 23
 
26 24
     /**
@@ -29,7 +27,8 @@ public class MathUtilities {
29 27
      * @return sum of `baseValue` and `difference`
30 28
      */
31 29
     public Short add(short baseValue, short difference) {
32
-        return null;
30
+        short sumShort = (short) (baseValue + difference);
31
+        return sumShort;
33 32
     }
34 33
 
35 34
     /**
@@ -38,7 +37,8 @@ public class MathUtilities {
38 37
      * @return sum of `baseValue` and `difference`
39 38
      */
40 39
     public Byte add(byte baseValue, byte difference) {
41
-        return null;
40
+        byte sumByte = (byte) (baseValue + difference);
41
+        return sumByte;
42 42
     }
43 43
 
44 44
     /**
@@ -47,7 +47,7 @@ public class MathUtilities {
47 47
      * @return sum of `baseValue` and `difference`
48 48
      */
49 49
     public Float add(float baseValue, float difference) {
50
-        return null;
50
+        return baseValue + difference;
51 51
     }
52 52
 
53 53
     /**
@@ -56,7 +56,7 @@ public class MathUtilities {
56 56
      * @return sum of `baseValue` and `difference`
57 57
      */
58 58
     public Double add(double baseValue, double difference) {
59
-        return null;
59
+        return baseValue + difference;
60 60
     }
61 61
 
62 62
     /**
@@ -65,7 +65,7 @@ public class MathUtilities {
65 65
      * @return difference between `baseValue` and `difference`
66 66
      */
67 67
     public Integer subtract(int baseValue, int difference) {
68
-        return null;
68
+        return baseValue - difference;
69 69
     }
70 70
 
71 71
     /**
@@ -74,7 +74,7 @@ public class MathUtilities {
74 74
      * @return difference between `baseValue` and `difference`
75 75
      */
76 76
     public Long subtract(long baseValue, long difference) {
77
-        return null;
77
+        return baseValue - difference;
78 78
     }
79 79
 
80 80
     /**
@@ -83,7 +83,8 @@ public class MathUtilities {
83 83
      * @return difference between `baseValue` and `difference`
84 84
      */
85 85
     public Short subtract(short baseValue, short difference) {
86
-        return null;
86
+        short minusShort = (short) (baseValue - difference);
87
+        return minusShort;
87 88
     }
88 89
 
89 90
     /**
@@ -92,7 +93,8 @@ public class MathUtilities {
92 93
      * @return difference between `baseValue` and `difference`
93 94
      */
94 95
     public Byte subtract(byte baseValue, byte difference) {
95
-        return null;
96
+        byte minusByte = (byte) (baseValue - difference);
97
+        return minusByte;
96 98
     }
97 99
 
98 100
     /**
@@ -101,7 +103,7 @@ public class MathUtilities {
101 103
      * @return difference between `baseValue` and `difference`
102 104
      */
103 105
     public Float subtract(float baseValue, float difference) {
104
-        return null;
106
+        return (baseValue - difference);
105 107
     }
106 108
 
107 109
     /**
@@ -110,131 +112,136 @@ public class MathUtilities {
110 112
      * @return difference between `baseValue` and `difference`
111 113
      */
112 114
     public Double subtract(double baseValue, double difference) {
113
-        return null;
115
+        return (baseValue - difference);
114 116
     }
115 117
 
116 118
 
117 119
     /**
118 120
      * @param dividend value to be divided
119
-     * @param divisor value to divide by
121
+     * @param divisor  value to divide by
120 122
      * @return division of `dividend` by `divisor
121 123
      */
122 124
     public Integer divide(int dividend, int divisor) {
123
-        return null;
125
+        return (dividend / divisor);
124 126
     }
125 127
 
126 128
     /**
127 129
      * @param dividend value to be divided
128
-     * @param divisor value to divide by
130
+     * @param divisor  value to divide by
129 131
      * @return division of `dividend` by `divisor
130 132
      */
131 133
     public Long divide(long dividend, long divisor) {
132
-        return null;
134
+        return (dividend / divisor);
133 135
     }
134 136
 
135 137
     /**
136 138
      * @param dividend value to be divided
137
-     * @param divisor value to divide by
139
+     * @param divisor  value to divide by
138 140
      * @return division of `dividend` by `divisor
139 141
      */
140 142
     public Short divide(short dividend, short divisor) {
141
-        return null;
143
+        short divShort = (short) (dividend / divisor);
144
+        return divShort;
142 145
     }
143 146
 
144 147
     /**
145 148
      * @param dividend value to be divided
146
-     * @param divisor value to divide by
149
+     * @param divisor  value to divide by
147 150
      * @return division of `dividend` by `divisor
148 151
      */
149 152
     public Byte divide(byte dividend, byte divisor) {
150
-        return null;
153
+        byte divByte = (byte) (dividend / divisor);
154
+        return divByte;
151 155
     }
152 156
 
153 157
     /**
154 158
      * @param dividend value to be divided
155
-     * @param divisor value to divide by
159
+     * @param divisor  value to divide by
156 160
      * @return division of `dividend` by `divisor
157 161
      */
158 162
     public Float divide(float dividend, float divisor) {
159
-        return null;
163
+        return (dividend / divisor);
160 164
     }
161 165
 
162 166
     /**
163 167
      * @param dividend value to be divided
164
-     * @param divisor value to divide by
168
+     * @param divisor  value to divide by
165 169
      * @return division of `dividend` by `divisor
166 170
      */
167 171
     public Double divide(double dividend, double divisor) {
168
-        return null;
172
+        return (dividend / divisor);
169 173
     }
170 174
 
171 175
 
172 176
     /**
173 177
      * @param multiplicand value to be multiplied
174
-     * @param multiplier value to multiply by
178
+     * @param multiplier   value to multiply by
175 179
      * @return product of `multiplicand` by `multiplier`
176 180
      */
177 181
     public Integer multiply(int multiplicand, int multiplier) {
178
-        return null;
182
+        return (multiplicand * multiplier);
179 183
     }
180 184
 
181 185
     /**
182 186
      * @param multiplicand value to be multiplied
183
-     * @param multiplier value to multiply by
187
+     * @param multiplier   value to multiply by
184 188
      * @return product of `multiplicand` by `multiplier`
185 189
      */
186 190
     public Long multiply(long multiplicand, long multiplier) {
187
-        return null;
191
+        return (multiplicand * multiplier);
188 192
     }
189 193
 
190 194
     /**
191 195
      * @param multiplicand value to be multiplied
192
-     * @param multiplier value to multiply by
196
+     * @param multiplier   value to multiply by
193 197
      * @return product of `multiplicand` by `multiplier`
194 198
      */
195 199
     public Short multiply(short multiplicand, short multiplier) {
196
-        return null;
200
+        short multShort = (short) (multiplicand * multiplier);
201
+        return multShort;
197 202
     }
203
+
198 204
     /**
199 205
      * @param multiplicand value to be multiplied
200
-     * @param multiplier value to multiply by
206
+     * @param multiplier   value to multiply by
201 207
      * @return product of `multiplicand` by `multiplier`
202 208
      */
203 209
     public Byte multiply(byte multiplicand, byte multiplier) {
204
-        return null;
210
+        byte multByte = (byte) (multiplicand * multiplier);
211
+        return multByte;
205 212
     }
206 213
 
207 214
     /**
208 215
      * @param multiplicand value to be multiplied
209
-     * @param multiplier value to multiply by
216
+     * @param multiplier   value to multiply by
210 217
      * @return product of `multiplicand` by `multiplier`
211 218
      */
212 219
     public Float multiply(float multiplicand, float multiplier) {
213
-        return null;
220
+        return (multiplicand * multiplier);
214 221
     }
215 222
 
216 223
     /**
217 224
      * @param multiplicand value to be multiplied
218
-     * @param multiplier value to multiply by
225
+     * @param multiplier   value to multiply by
219 226
      * @return product of `multiplicand` by `multiplier`
220 227
      */
221 228
     public Double multiply(double multiplicand, double multiplier) {
222
-        return null;
229
+        return (multiplicand * multiplier);
223 230
     }
224 231
 
225 232
 
226 233
     /**
227
-      * @return true
234
+     * @return true
228 235
      */
229 236
     public Boolean returnTrue() {
230
-        return null;
237
+        return true;
231 238
     }
232 239
 
233 240
     /**
234 241
      * @return false
235 242
      */
236 243
     public Boolean returnFalse() {
237
-        return null;
244
+        return false;
238 245
     }
239 246
 
240 247
 }

+ 32
- 5
src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java Zobrazit soubor

@@ -1,4 +1,3 @@
1
-package com.zipcodewilmington.danny_do_better_exercises;
2 1
 
3 2
 /**
4 3
  * Created by dan on 6/14/17.
@@ -10,7 +9,14 @@ public class PredicateUtilities {
10 9
      * @return true if `x` is greater than `y`
11 10
      */
12 11
     public Boolean isGreaterThan(int x, int y) {
13
-        return null;
12
+        boolean z;
13
+
14
+        if (x > y) {
15
+            z = true;
16
+        } else {
17
+            z = false;
18
+        }
19
+        return z;
14 20
     }
15 21
 
16 22
     /**
@@ -19,7 +25,14 @@ public class PredicateUtilities {
19 25
      * @return true if `x` is less than `y`
20 26
      */
21 27
     public Boolean isLessThan(int x, int y) {
22
-        return null;
28
+        boolean z;
29
+
30
+        if (x < y) {
31
+            z = true;
32
+        } else {
33
+            z = false;
34
+        }
35
+        return z;
23 36
     }
24 37
 
25 38
     /**
@@ -28,7 +41,14 @@ public class PredicateUtilities {
28 41
      * @return true if `x` is greater than or equal to `y`
29 42
      */
30 43
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
31
-        return null;
44
+        boolean z;
45
+
46
+        if (x >= y) {
47
+            z = true;
48
+        } else {
49
+            z = false;
50
+        }
51
+        return z;
32 52
     }
33 53
 
34 54
     /**
@@ -37,6 +57,13 @@ public class PredicateUtilities {
37 57
      * @return true if `x` is less than or equal to `y`
38 58
      */
39 59
     public Boolean isLessThanOrEqualTo(int x, int y) {
40
-        return null;
60
+        boolean z;
61
+
62
+        if (x <= y) {
63
+            z = true;
64
+        } else {
65
+            z = false;
66
+        }
67
+        return z;
41 68
     }
42 69
 }

+ 38
- 12
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java Zobrazit soubor

@@ -1,5 +1,3 @@
1
-package com.zipcodewilmington.danny_do_better_exercises;
2
-
3 1
 /**
4 2
  * Created by dan on 6/14/17.
5 3
  */
@@ -8,7 +6,8 @@ public class StringUtilities {
8 6
      * @return `Hello World` as a string
9 7
      */
10 8
     public static String getHelloWorld() {
11
-        return null;
9
+        String hello = "Hello World";
10
+        return hello;
12 11
     }
13 12
 
14 13
     /**
@@ -17,7 +16,8 @@ public class StringUtilities {
17 16
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18 17
      */
19 18
     public static String concatenation(String firstSegment, String secondSegment){
20
-        return null;
19
+        String conCat = firstSegment.concat(secondSegment);
20
+        return conCat;
21 21
     }
22 22
 
23 23
     /**
@@ -26,7 +26,8 @@ public class StringUtilities {
26 26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27 27
      */
28 28
     public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
29
+        String conCat2 = (firstSegment + secondSegment);
30
+        return conCat2;
30 31
     }
31 32
 
32 33
     /**
@@ -34,7 +35,8 @@ public class StringUtilities {
34 35
      * @return the first 3 characters of `input`
35 36
      */
36 37
     public static String getPrefix(String input){
37
-        return null;
38
+        String firstThree = input.substring(0, 3);        
39
+        return firstThree;
38 40
     }
39 41
 
40 42
     /**
@@ -42,7 +44,8 @@ public class StringUtilities {
42 44
      * @return the last 3 characters of `input`
43 45
      */
44 46
     public static String getSuffix(String input){
45
-        return null;
47
+        String lastThree = input.substring((input.length() - 3), (input.length()));
48
+        return lastThree;
46 49
     }
47 50
 
48 51
     /**
@@ -51,7 +54,8 @@ public class StringUtilities {
51 54
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52 55
      */
53 56
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
-        return null;
57
+        boolean stringEqual = inputValue.equalsIgnoreCase(comparableValue);        
58
+        return stringEqual;
55 59
     }
56 60
 
57 61
     /**
@@ -59,7 +63,9 @@ public class StringUtilities {
59 63
      * @return the middle character of `inputValue`
60 64
      */
61 65
     public static Character getMiddleCharacter(String inputValue){
62
-        return null;
66
+        int midCharLocation = (inputValue.length() - 1) / 2;  // gets index #
67
+        char midChar = inputValue.charAt(midCharLocation);
68
+        return midChar;
63 69
     }
64 70
 
65 71
     /**
@@ -67,7 +73,9 @@ public class StringUtilities {
67 73
      * @return the first sequence of characters
68 74
      */
69 75
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
76
+        int firstSpace = spaceDelimitedString.indexOf(" ");
77
+        String firstWord = spaceDelimitedString.substring(0, firstSpace);        
78
+        return firstWord;
71 79
     }
72 80
 
73 81
     /**
@@ -75,7 +83,20 @@ public class StringUtilities {
75 83
      * @return the second word of a string delimited by spaces.
76 84
      */
77 85
     public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
86
+        // find index of first space
87
+        int firstSpace = spaceDelimitedString.indexOf(" ");
88
+        // find index of second space
89
+        int secondSpace = spaceDelimitedString.indexOf(" ", firstSpace + 1);
90
+
91
+        String secondWord;
92
+        
93
+        if (secondSpace > 0) {
94
+            secondWord = spaceDelimitedString.substring(firstSpace, secondSpace);
95
+        } else {
96
+            secondWord = spaceDelimitedString.substring((firstSpace + 1),(spaceDelimitedString.length()));
97
+        }
98
+
99
+        return secondWord;
79 100
     }
80 101
 
81 102
     /**
@@ -83,6 +104,11 @@ public class StringUtilities {
83 104
      * @return an identical string with characters in reverse order.
84 105
      */
85 106
     public static String reverse(String stringToReverse){
86
-        return null;
107
+        // change string in stringbuilder
108
+        StringBuilder reverseSB = new StringBuilder(stringToReverse);
109
+        // use built-in stringbuilder reverse method and then change back to string
110
+        String reverse = reverseSB.reverse().toString();
111
+        
112
+        return reverse;
87 113
     }
88 114
 }

+ 1
- 1
src/main/java/com/zipcodewilmington/danny_do_better_exercises/ZipcodeRocks.java Zobrazit soubor

@@ -5,6 +5,6 @@ package com.zipcodewilmington.danny_do_better_exercises;
5 5
  */
6 6
 public class ZipcodeRocks {
7 7
     public static void main(String[] args) {
8
-//         System.out.println("Zipcode Rocks!");
8
+         System.out.println("Zipcode Rocks!");
9 9
     }
10 10
 }