소스 검색

pre-merge commit

De'Jon Johnson 6 년 전
부모
커밋
080759034d

+ 27
- 5
src/main/java/rocks/zipcode/io/quiz4/collections/ComparableTreeSet.java 파일 보기

1
 package rocks.zipcode.io.quiz4.collections;
1
 package rocks.zipcode.io.quiz4.collections;
2
 
2
 
3
+import java.util.TreeSet;
4
+
3
 /**
5
 /**
4
  * @author leon on 11/12/2018.
6
  * @author leon on 11/12/2018.
5
  */
7
  */
6
-public class ComparableTreeSet<_> {
7
-    public ComparableTreeSet(_... arr) {
8
-    }
8
+public class ComparableTreeSet<Element> implements Comparable<Element> {
9
+    private TreeSet<Element> treeset = new TreeSet<Element>();
10
+
11
+    public ComparableTreeSet(Element... arr) {
12
+
13
+        for(Element itemAdded : arr){
14
+            treeset.add(itemAdded);
15
+        }
9
 
16
 
17
+    }
18
+    public int size(){
19
+        return treeset.size();
20
+    }
10
 
21
 
11
     public ComparableTreeSet() {
22
     public ComparableTreeSet() {
12
     }
23
     }
13
 
24
 
14
-    public Integer compareTo(ComparableTreeSet<_> o) {
15
-        return null;
25
+    public Integer compareTo(ComparableTreeSet<Element> o) {
26
+        if (treeset.size() > o.size())
27
+          return 1;
28
+         else if (treeset.size() < o.size())
29
+           return -1;
30
+        else
31
+        return 0;
32
+        }
33
+
34
+
35
+    @Override
36
+    public int compareTo(Element o) {
37
+        return 0;
16
     }
38
     }
17
 }
39
 }

+ 34
- 5
src/main/java/rocks/zipcode/io/quiz4/collections/SimpleStringGroup.java 파일 보기

1
 package rocks.zipcode.io.quiz4.collections;
1
 package rocks.zipcode.io.quiz4.collections;
2
 
2
 
3
+import java.util.ArrayList;
4
+import java.util.Iterator;
5
+import java.util.List;
6
+import java.util.Spliterator;
7
+import java.util.function.Consumer;
8
+
3
 /**
9
 /**
4
  * @author leon on 11/12/2018.
10
  * @author leon on 11/12/2018.
5
  */
11
  */
6
-public class SimpleStringGroup {
12
+public class SimpleStringGroup implements Iterable {
13
+
14
+    private List<String> list = new ArrayList<String>();
15
+
16
+
7
     public SimpleStringGroup() {
17
     public SimpleStringGroup() {
8
-        throw new UnsupportedOperationException("Method not yet implemented");
18
+//        throw new UnsupportedOperationException("Method not yet implemented");
9
     }
19
     }
10
 
20
 
11
     public Integer count() {
21
     public Integer count() {
12
-        return null;
22
+        return list.size();
13
     }
23
     }
14
 
24
 
15
     public void insert(String string) {
25
     public void insert(String string) {
26
+        list.add(string);
16
     }
27
     }
17
 
28
 
18
     public Boolean has(String valueToInsert) {
29
     public Boolean has(String valueToInsert) {
19
-        return null;
30
+        return list.contains(valueToInsert);
20
     }
31
     }
21
 
32
 
22
     public String fetch(int indexOfValue) {
33
     public String fetch(int indexOfValue) {
23
-        return null;
34
+        return list.get(indexOfValue);
24
     }
35
     }
25
 
36
 
26
     public void delete(String valueToInsert) {
37
     public void delete(String valueToInsert) {
38
+        list.remove(valueToInsert);
27
     }
39
     }
28
 
40
 
29
     public void clear() {
41
     public void clear() {
42
+        list.clear();
43
+    }
44
+
45
+    @Override
46
+    public Iterator iterator() {
47
+        return list.iterator();
48
+    }
49
+    @Override
50
+public void forEach(Consumer action) {
51
+        list.forEach(action);
52
+        }
53
+  @Override
54
+public Spliterator spliterator() {
55
+     return list.spliterator();
56
+
30
     }
57
     }
58
+
59
+
31
 }
60
 }

+ 25
- 4
src/main/java/rocks/zipcode/io/quiz4/collections/ZipCodeWilmington.java 파일 보기

2
 
2
 
3
 import rocks.zipcode.io.quiz4.objectorientation.Student;
3
 import rocks.zipcode.io.quiz4.objectorientation.Student;
4
 
4
 
5
+import java.util.ArrayList;
6
+import java.util.HashMap;
7
+import java.util.List;
5
 import java.util.Map;
8
 import java.util.Map;
6
 
9
 
7
 /**
10
 /**
8
  * @author leon on 11/12/2018.
11
  * @author leon on 11/12/2018.
9
  */
12
  */
10
 public class ZipCodeWilmington {
13
 public class ZipCodeWilmington {
14
+
15
+    private List<Student> students = new ArrayList<>();
16
+
17
+    public ZipCodeWilmington() {
18
+          this.students = new ArrayList<>();
19
+         }
20
+
11
     public void enroll(Student student) {
21
     public void enroll(Student student) {
22
+        this.students.add(student);
12
     }
23
     }
13
 
24
 
14
     public Boolean isEnrolled(Student student) {
25
     public Boolean isEnrolled(Student student) {
15
-        return null;
26
+
27
+        return students.contains(student);
16
     }
28
     }
17
 
29
 
18
     public void lecture(double numberOfHours) {
30
     public void lecture(double numberOfHours) {
31
+        for (Student dork : this.students) {
32
+            dork.learn(numberOfHours);
33
+        }
19
     }
34
     }
20
 
35
 
21
-    public Map<Student, Double> getStudyMap() {
22
-        return null;
36
+        public Map<Student, Double> getStudyMap () {
37
+
38
+            Map<Student, Double> map = new HashMap<>();
39
+            for (Student dork : this.students) {
40
+                map.put(dork, dork.getTotalStudyTime());
41
+            }
42
+            return map;
43
+        }
23
     }
44
     }
24
-}
45
+

+ 7
- 0
src/main/java/rocks/zipcode/io/quiz4/fundamentals/PalindromeEvaluator.java 파일 보기

1
 package rocks.zipcode.io.quiz4.fundamentals;
1
 package rocks.zipcode.io.quiz4.fundamentals;
2
 
2
 
3
+import java.util.ArrayList;
4
+import java.util.List;
5
+
3
 /**
6
 /**
4
  * @author leon on 18/12/2018.
7
  * @author leon on 18/12/2018.
5
  */
8
  */
6
 public class PalindromeEvaluator {
9
 public class PalindromeEvaluator {
10
+
11
+
7
     public static String[] getAllPalindromes(String string) {
12
     public static String[] getAllPalindromes(String string) {
13
+
14
+
8
         return null;
15
         return null;
9
     }
16
     }
10
 
17
 

+ 3
- 0
src/main/java/rocks/zipcode/io/quiz4/fundamentals/StringEvaluator.java 파일 보기

5
  */
5
  */
6
 public class StringEvaluator {
6
 public class StringEvaluator {
7
     public static String[] getAllPrefixes(String string) {
7
     public static String[] getAllPrefixes(String string) {
8
+
8
         return null;
9
         return null;
9
     }
10
     }
10
 
11
 
11
     public static String[] getCommonPrefixes(String string1, String string2) {
12
     public static String[] getCommonPrefixes(String string1, String string2) {
13
+
12
         return null;
14
         return null;
13
     }
15
     }
14
 
16
 
15
     public static String getLargestCommonPrefix(String string1, String string2) {
17
     public static String getLargestCommonPrefix(String string1, String string2) {
18
+
16
         return null;
19
         return null;
17
     }
20
     }
18
 }
21
 }