Selaa lähdekoodia

More problems done

rayskeez21 8 vuotta sitten
vanhempi
commit
c34fe5a6de
2 muutettua tiedostoa jossa 34 lisäystä ja 8 poistoa
  1. 32
    6
      StringArrayUtils.java
  2. 2
    2
      package.bluej

+ 32
- 6
StringArrayUtils.java Näytä tiedosto

@@ -83,13 +83,25 @@ public class StringArrayUtils {
83 83
      * @return true if each letter in the alphabet has been used in the array
84 84
      */ // TODO
85 85
     public static boolean isPangramic(String[] array) {
86
-
86
+        boolean my = true;
87 87
         for(char alphabet = 'a'; alphabet <= 'z'; alphabet++){
88
-            if(alphabet >= 'a' && alphabet <= 'z'){
89
-                return true;
88
+            boolean iKnow = false;
89
+
90
+            for(int i = 0; i < array.length; i++){
91
+                if(array[i].toLowerCase().contains(Character.toString(alphabet))){
92
+
93
+                    iKnow = true;
94
+                    break;
95
+
96
+                }
97
+
98
+            }
99
+            if(!iKnow){
100
+                my = false; 
101
+                break;
90 102
             }
91 103
         }
92
-        return false;
104
+        return my;
93 105
     }
94 106
 
95 107
     /**
@@ -113,15 +125,29 @@ public class StringArrayUtils {
113 125
      * @return array with identical contents excluding values of `value`
114 126
      */ // TODO
115 127
     public static String[] removeValue(String[] array, String valueToRemove) {
116
-        return null;
128
+        int count = getNumberOfOccurrences(array,valueToRemove);
129
+        String[] cheese = new String[array.length - count];
130
+        int j = 0;
131
+        for(int i = 0; i < array.length; i++){
132
+            if(array[i] != valueToRemove){
133
+                cheese[j] = array[i];
134
+                j++;
135
+            }
136
+        }
137
+
138
+        return cheese;
117 139
     }
118 140
 
119
-    /**
141
+    /*
120 142
      * @param array array of chars
121 143
      * @return array of Strings with consecutive duplicates removes
122 144
      */ // TODO
123 145
     public static String[] removeConsecutiveDuplicates(String[] array) {
146
+        String removeThese = new String();
147
+        int duplicate = getNumberOfOccurrences(array,removeThese);
148
+        
124 149
         return null;
150
+        
125 151
     }
126 152
 
127 153
     /**

+ 2
- 2
package.bluej Näytä tiedosto

@@ -5,14 +5,14 @@ dependency1.type=UsesDependency
5 5
 editor.fx.0.height=722
6 6
 editor.fx.0.width=800
7 7
 editor.fx.0.x=240
8
-editor.fx.0.y=23
8
+editor.fx.0.y=24
9 9
 objectbench.height=101
10 10
 objectbench.width=461
11 11
 package.divider.horizontal=0.6
12 12
 package.divider.vertical=0.8007380073800738
13 13
 package.editor.height=427
14 14
 package.editor.width=674
15
-package.editor.x=0
15
+package.editor.x=57
16 16
 package.editor.y=23
17 17
 package.frame.height=600
18 18
 package.frame.width=800