Nuridalia Hermandez 6 лет назад
Родитель
Сommit
a9739a2ea9
6 измененных файлов: 65 добавлений и 33 удалений
  1. Двоичные данные
      MathUtilities.class
  2. 30
    19
      MathUtilities.java
  3. Двоичные данные
      StringUtilities.class
  4. 1
    1
      StringUtilities.ctxt
  5. 30
    9
      StringUtilities.java
  6. 4
    4
      package.bluej

Двоичные данные
MathUtilities.class Просмотреть файл


+ 30
- 19
MathUtilities.java Просмотреть файл

1
- 
2
 
1
 
3
 /**
2
 /**
4
  * Created by dan on 6/14/17.
3
  * Created by dan on 6/14/17.
29
      * @return sum of `baseValue` and `difference`
28
      * @return sum of `baseValue` and `difference`
30
      */
29
      */
31
     public Short add(short baseValue, short difference) {
30
     public Short add(short baseValue, short difference) {
32
-        return null;
31
+        int x =  baseValue+  difference;
32
+        return   (short)x;
33
     }
33
     }
34
 
34
 
35
     /**
35
     /**
38
      * @return sum of `baseValue` and `difference`
38
      * @return sum of `baseValue` and `difference`
39
      */
39
      */
40
     public Byte add(byte baseValue, byte difference) {
40
     public Byte add(byte baseValue, byte difference) {
41
-        
42
-        return null;
41
+        int x = baseValue +difference;
42
+        return (byte) x;
43
     }
43
     }
44
 
44
 
45
     /**
45
     /**
48
      * @return sum of `baseValue` and `difference`
48
      * @return sum of `baseValue` and `difference`
49
      */
49
      */
50
     public Float add(float baseValue, float difference) {
50
     public Float add(float baseValue, float difference) {
51
-        return null;
51
+
52
+        return baseValue + difference;
52
     }
53
     }
53
 
54
 
54
     /**
55
     /**
75
      * @return difference between `baseValue` and `difference`
76
      * @return difference between `baseValue` and `difference`
76
      */
77
      */
77
     public Long subtract(long baseValue, long difference) {
78
     public Long subtract(long baseValue, long difference) {
78
-        return null;
79
+        double x = baseValue - difference;
80
+        return (long) x;
81
+
79
     }
82
     }
80
 
83
 
81
     /**
84
     /**
84
      * @return difference between `baseValue` and `difference`
87
      * @return difference between `baseValue` and `difference`
85
      */
88
      */
86
     public Short subtract(short baseValue, short difference) {
89
     public Short subtract(short baseValue, short difference) {
87
-        return null;
90
+        int x = baseValue -difference;
91
+        return (short) x;
92
+
88
     }
93
     }
89
 
94
 
90
     /**
95
     /**
93
      * @return difference between `baseValue` and `difference`
98
      * @return difference between `baseValue` and `difference`
94
      */
99
      */
95
     public Byte subtract(byte baseValue, byte difference) {
100
     public Byte subtract(byte baseValue, byte difference) {
96
-        return null;
101
+        int x = baseValue -difference;
102
+        return (byte) x;
97
     }
103
     }
98
 
104
 
99
     /**
105
     /**
102
      * @return difference between `baseValue` and `difference`
108
      * @return difference between `baseValue` and `difference`
103
      */
109
      */
104
     public Float subtract(float baseValue, float difference) {
110
     public Float subtract(float baseValue, float difference) {
105
-        return null;
111
+        return  baseValue- difference;
106
     }
112
     }
107
 
113
 
108
     /**
114
     /**
114
         return baseValue - difference;
120
         return baseValue - difference;
115
     }
121
     }
116
 
122
 
117
-
118
     /**
123
     /**
119
      * @param dividend value to be divided
124
      * @param dividend value to be divided
120
      * @param divisor value to divide by
125
      * @param divisor value to divide by
139
      * @return division of `dividend` by `divisor
144
      * @return division of `dividend` by `divisor
140
      */
145
      */
141
     public Short divide(short dividend, short divisor) {
146
     public Short divide(short dividend, short divisor) {
142
-        return null;
147
+        int x =dividend /divisor;
148
+        return (short) x;
143
     }
149
     }
144
 
150
 
145
     /**
151
     /**
148
      * @return division of `dividend` by `divisor
154
      * @return division of `dividend` by `divisor
149
      */
155
      */
150
     public Byte divide(byte dividend, byte divisor) {
156
     public Byte divide(byte dividend, byte divisor) {
151
-        return null;
157
+         int x =dividend /divisor;
158
+        return (byte) x;
152
     }
159
     }
153
 
160
 
154
     /**
161
     /**
169
         return dividend/divisor;
176
         return dividend/divisor;
170
     }
177
     }
171
 
178
 
172
-
173
     /**
179
     /**
174
      * @param multiplicand value to be multiplied
180
      * @param multiplicand value to be multiplied
175
      * @param multiplier value to multiply by
181
      * @param multiplier value to multiply by
185
      * @return product of `multiplicand` by `multiplier`
191
      * @return product of `multiplicand` by `multiplier`
186
      */
192
      */
187
     public Long multiply(long multiplicand, long multiplier) {
193
     public Long multiply(long multiplicand, long multiplier) {
188
-        return null;
194
+         double x =multiplicand * multiplier;
195
+        return (long) x;
189
     }
196
     }
190
 
197
 
191
     /**
198
     /**
194
      * @return product of `multiplicand` by `multiplier`
201
      * @return product of `multiplicand` by `multiplier`
195
      */
202
      */
196
     public Short multiply(short multiplicand, short multiplier) {
203
     public Short multiply(short multiplicand, short multiplier) {
197
-        return null;
204
+         int x =multiplicand * multiplier;
205
+        return (short) x;
206
+    
198
     }
207
     }
208
+
199
     /**
209
     /**
200
      * @param multiplicand value to be multiplied
210
      * @param multiplicand value to be multiplied
201
      * @param multiplier value to multiply by
211
      * @param multiplier value to multiply by
202
      * @return product of `multiplicand` by `multiplier`
212
      * @return product of `multiplicand` by `multiplier`
203
      */
213
      */
204
     public Byte multiply(byte multiplicand, byte multiplier) {
214
     public Byte multiply(byte multiplicand, byte multiplier) {
205
-        return null;
215
+         int x =multiplicand * multiplier;
216
+        return (byte) x;
217
+    
206
     }
218
     }
207
 
219
 
208
     /**
220
     /**
211
      * @return product of `multiplicand` by `multiplier`
223
      * @return product of `multiplicand` by `multiplier`
212
      */
224
      */
213
     public Float multiply(float multiplicand, float multiplier) {
225
     public Float multiply(float multiplicand, float multiplier) {
214
-        return null;
226
+        return multiplicand*multiplier;
215
     }
227
     }
216
 
228
 
217
     /**
229
     /**
223
         return multiplicand * multiplier ;
235
         return multiplicand * multiplier ;
224
     }
236
     }
225
 
237
 
226
-
227
     /**
238
     /**
228
-      * @return true
239
+     * @return true
229
      */
240
      */
230
     public Boolean returnTrue() {
241
     public Boolean returnTrue() {
231
         return true;
242
         return true;

Двоичные данные
StringUtilities.class Просмотреть файл


+ 1
- 1
StringUtilities.ctxt Просмотреть файл

27
 comment7.text=\n\ @param\ inputValue\ the\ value\ input\ from\ user\n\ @return\ the\ middle\ character\ of\ `inputValue`\n
27
 comment7.text=\n\ @param\ inputValue\ the\ value\ input\ from\ user\n\ @return\ the\ middle\ character\ of\ `inputValue`\n
28
 comment8.params=spaceDelimitedString
28
 comment8.params=spaceDelimitedString
29
 comment8.target=java.lang.String\ getFirstWord(java.lang.String)
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
30
+comment8.text=\n\ \ \ \ a\ *\ @param\ spaceDelimitedString\ a\ string,\ representative\ of\ a\ sentence,\ containing\ spaces\n\ @return\ the\ first\ sequence\ of\ characters\n
31
 comment9.params=spaceDelimitedString
31
 comment9.params=spaceDelimitedString
32
 comment9.target=java.lang.String\ getSecondWord(java.lang.String)
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
33
 comment9.text=\n\ @param\ spaceDelimitedString\ a\ string\ delimited\ by\ spaces\n\ @return\ the\ second\ word\ of\ a\ string\ delimited\ by\ spaces.\n

+ 30
- 9
StringUtilities.java Просмотреть файл

1
- 
2
 
1
 
3
 /**
2
 /**
4
  * Created by dan on 6/14/17.
3
  * Created by dan on 6/14/17.
28
     public static String concatenation(int firstSegment, String secondSegment){
27
     public static String concatenation(int firstSegment, String secondSegment){
29
         String n = Integer.toString(firstSegment);
28
         String n = Integer.toString(firstSegment);
30
         return n + secondSegment;
29
         return n + secondSegment;
31
-        
32
-        
30
+
33
     }
31
     }
34
 
32
 
35
     /**
33
     /**
62
      * @return the middle character of `inputValue`
60
      * @return the middle character of `inputValue`
63
      */
61
      */
64
     public static Character getMiddleCharacter(String inputValue){
62
     public static Character getMiddleCharacter(String inputValue){
65
-        return inputValue.charAt(inputValue.length()/2);
63
+        int post;
64
+        int leng;
65
+        if (inputValue.length()% 2 == 1){
66
+            post=inputValue.length()/2;
67
+            leng= 1;
68
+        } else {
69
+            post=inputValue.length()/2-1;
70
+            leng = 2; 
71
+        }
72
+        String mid = inputValue.substring(post, post
73
+                + leng);
74
+                char output = mid.charAt(0);
75
+        return output;//inputValue.charAt(inputValue.length()/2);
66
     }
76
     }
67
 
77
 
68
     /**
78
     /**
69
-     * @param spaceDelimitedString a string, representative of a sentence, containing spaces
79
+    a * @param spaceDelimitedString a string, representative of a sentence, containing spaces
70
      * @return the first sequence of characters
80
      * @return the first sequence of characters
71
      */
81
      */
72
     public static String getFirstWord(String spaceDelimitedString){
82
     public static String getFirstWord(String spaceDelimitedString){
73
-        String str= spaceDelimitedString.split(" ");
74
-        return  ;
83
+        int str= spaceDelimitedString.indexOf(" ");
84
+        String word = spaceDelimitedString.substring(0, str);
85
+
86
+        return word ;
75
     }
87
     }
76
 
88
 
77
     /**
89
     /**
79
      * @return the second word of a string delimited by spaces.
91
      * @return the second word of a string delimited by spaces.
80
      */
92
      */
81
     public static String getSecondWord(String spaceDelimitedString){
93
     public static String getSecondWord(String spaceDelimitedString){
82
-        return null;
94
+        /**int word = spaceDelimitedString.indexOf(" ");
95
+        int word1 = spaceDelimitedString.indexOf("", word );
96
+        String secondWord=spaceDelimitedString.substring(word , word1);
97
+        return secondWord;*/
98
+        return spaceDelimitedString.split(" ")[1];
83
     }
99
     }
84
 
100
 
85
     /**
101
     /**
87
      * @return an identical string with characters in reverse order.
103
      * @return an identical string with characters in reverse order.
88
      */
104
      */
89
     public static String reverse(String stringToReverse){
105
     public static String reverse(String stringToReverse){
90
-        return null;
106
+        String reverse="";
107
+        for(int i = stringToReverse.length() - 1; i >= 0; i--)
108
+        {
109
+            reverse = reverse+ stringToReverse.charAt(i);
110
+        }
111
+        return reverse;
91
     }
112
     }
92
 }
113
 }

+ 4
- 4
package.bluej Просмотреть файл

1
 #BlueJ package file
1
 #BlueJ package file
2
-editor.fx.0.height=712
3
-editor.fx.0.width=876
4
-editor.fx.0.x=365
5
-editor.fx.0.y=189
2
+editor.fx.0.height=0
3
+editor.fx.0.width=0
4
+editor.fx.0.x=0
5
+editor.fx.0.y=0
6
 objectbench.height=128
6
 objectbench.height=128
7
 objectbench.width=1171
7
 objectbench.width=1171
8
 package.divider.horizontal=0.6
8
 package.divider.horizontal=0.6