Bläddra i källkod

More problems done

rayskeez21 8 år sedan
förälder
incheckning
c34fe5a6de
2 ändrade filer med 34 tillägg och 8 borttagningar
  1. 32
    6
      StringArrayUtils.java
  2. 2
    2
      package.bluej

+ 32
- 6
StringArrayUtils.java Visa fil

83
      * @return true if each letter in the alphabet has been used in the array
83
      * @return true if each letter in the alphabet has been used in the array
84
      */ // TODO
84
      */ // TODO
85
     public static boolean isPangramic(String[] array) {
85
     public static boolean isPangramic(String[] array) {
86
-
86
+        boolean my = true;
87
         for(char alphabet = 'a'; alphabet <= 'z'; alphabet++){
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
      * @return array with identical contents excluding values of `value`
125
      * @return array with identical contents excluding values of `value`
114
      */ // TODO
126
      */ // TODO
115
     public static String[] removeValue(String[] array, String valueToRemove) {
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
      * @param array array of chars
142
      * @param array array of chars
121
      * @return array of Strings with consecutive duplicates removes
143
      * @return array of Strings with consecutive duplicates removes
122
      */ // TODO
144
      */ // TODO
123
     public static String[] removeConsecutiveDuplicates(String[] array) {
145
     public static String[] removeConsecutiveDuplicates(String[] array) {
146
+        String removeThese = new String();
147
+        int duplicate = getNumberOfOccurrences(array,removeThese);
148
+        
124
         return null;
149
         return null;
150
+        
125
     }
151
     }
126
 
152
 
127
     /**
153
     /**

+ 2
- 2
package.bluej Visa fil

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