ソースを参照

Some stuff done

William Brown 6 年 前
コミット
62ad074aca

+ 6
- 2
src/main/java/rocks/zipcode/io/quiz4/collections/ComparableTreeSet.java ファイルの表示

@@ -5,14 +5,18 @@ package rocks.zipcode.io.quiz4.collections;
5 5
  */
6 6
 public class ComparableTreeSet<_> {
7 7
     public ComparableTreeSet(_... arr) {
8
-    }
9 8
 
9
+    }
10 10
 
11
-    
12 11
     public ComparableTreeSet() {
12
+        
13 13
     }
14 14
 
15 15
     public Integer compareTo(ComparableTreeSet<_> o) {
16 16
         return null;
17 17
     }
18
+
19
+    public String toString(){
20
+        return null;
21
+    }
18 22
 }

+ 10
- 1
src/main/java/rocks/zipcode/io/quiz4/collections/ZipCodeWilmington.java ファイルの表示

@@ -2,20 +2,29 @@ package rocks.zipcode.io.quiz4.collections;
2 2
 
3 3
 import rocks.zipcode.io.quiz4.objectorientation.Student;
4 4
 
5
+import java.util.ArrayList;
6
+import java.util.HashMap;
5 7
 import java.util.Map;
6 8
 
7 9
 /**
8 10
  * @author leon on 11/12/2018.
9 11
  */
10 12
 public class ZipCodeWilmington {
13
+
14
+    private ArrayList<Student> students = new ArrayList<>();
15
+
11 16
     public void enroll(Student student) {
17
+        this.students.add(student);
12 18
     }
13 19
 
14 20
     public Boolean isEnrolled(Student student) {
15
-        return null;
21
+        return this.students.contains(student);
16 22
     }
17 23
 
18 24
     public void lecture(double numberOfHours) {
25
+        for(Student i : students){
26
+            i.learn(numberOfHours/students.size());
27
+        }
19 28
     }
20 29
 
21 30
     public Map<Student, Double> getStudyMap() {

+ 16
- 1
src/main/java/rocks/zipcode/io/quiz4/fundamentals/StringEvaluator.java ファイルの表示

@@ -1,11 +1,26 @@
1 1
 package rocks.zipcode.io.quiz4.fundamentals;
2 2
 
3
+import java.util.ArrayList;
4
+import java.util.Arrays;
5
+import java.util.List;
6
+
3 7
 /**
4 8
  * @author leon on 11/12/2018.
5 9
  */
6 10
 public class StringEvaluator {
7 11
     public static String[] getAllPrefixes(String string) {
8
-        return null;
12
+
13
+        String[] output = new String[(string.length() - 1 )*(string.length() - 1)];
14
+        int count = 0;
15
+
16
+        for(int i = 0; i < string.length() - 1; i++){
17
+            for(int j = 0; j < string.length() - 1; j++){
18
+                output[count] = (string.substring(i, j));
19
+                count++;
20
+            }
21
+        }
22
+
23
+        return output;
9 24
     }
10 25
 
11 26
     public static String[] getCommonPrefixes(String string1, String string2) {

+ 9
- 3
src/main/java/rocks/zipcode/io/quiz4/objectorientation/Student.java ファイルの表示

@@ -4,17 +4,23 @@ package rocks.zipcode.io.quiz4.objectorientation;
4 4
  * @author leon on 11/12/2018.
5 5
  */
6 6
 public class Student {
7
+
8
+    private Double totalStudyTime;
9
+    private Integer id;
10
+
7 11
     public Student() {
8
-        this(null);
12
+        this.id = null;
9 13
     }
10 14
 
11 15
     public Student(Integer id) {
16
+        this.id = id;
12 17
     }
13 18
 
14 19
     public void learn(Double amountOfHours) {
20
+        totalStudyTime =+ amountOfHours;
15 21
     }
16 22
 
17 23
     public Double getTotalStudyTime() {
18
-        return null;
24
+        return this.totalStudyTime;
19 25
     }
20
-}
26
+}