Kate Moore 6 лет назад
Родитель
Сommit
63acf4e688

+ 2
- 0
src/main/java/rocks/zipcode/io/quiz4/collections/ComparableTreeSet.java Просмотреть файл

@@ -6,6 +6,8 @@ import java.util.Comparator;
6 6
  * @author leon on 11/12/2018.
7 7
  */
8 8
 public class ComparableTreeSet<_> {
9
+
10
+
9 11
     public ComparableTreeSet(_... arr) {
10 12
     }
11 13
 

+ 1
- 1
src/main/java/rocks/zipcode/io/quiz4/collections/ZipCodeWilmington.java Просмотреть файл

@@ -30,7 +30,7 @@ public class ZipCodeWilmington {
30 30
     }
31 31
 
32 32
     public void lecture(double numberOfHours) {
33
-
33
+        student.learn(numberOfHours);
34 34
     }
35 35
 
36 36
     public Map<Student, Double> getStudyMap() {

+ 4
- 2
src/main/java/rocks/zipcode/io/quiz4/generics/GenericUtils.java Просмотреть файл

@@ -9,11 +9,13 @@ import java.util.TreeSet;
9 9
  * @author leon on 11/12/2018.
10 10
  */
11 11
 public class GenericUtils {
12
-    public static <T extends Comparable> Iterable<Iterable<T>> powerSet(Set<T> originalSet) {
12
+
13
+    public static <_ extends Comparable> Iterable<? extends Iterable<_>> powerSet(Set<_> originalSet) {
13 14
         return null;
14 15
     }
15 16
 
16
-    public static <T extends Comparable> Iterable<Iterable<T>> powerSet(T... originalSet) {
17
+    public static <_ extends Comparable> Iterable<? extends Iterable<_>> powerSet(_... originalSet) {
17 18
         return powerSet(new TreeSet<>(Arrays.asList(originalSet)));
18 19
    }
19 20
 }
21
+

+ 19
- 5
src/main/java/rocks/zipcode/io/quiz4/generics/MyStack.java Просмотреть файл

@@ -1,25 +1,39 @@
1 1
 package rocks.zipcode.io.quiz4.generics;
2 2
 
3
+import java.util.Iterator;
4
+import java.util.Stack;
5
+
3 6
 /**
4 7
  * @author leon on 11/12/2018.
5 8
  */
6
-public class MyStack<SomeType> {
9
+public class MyStack<SomeType> implements Iterable {
10
+    Stack<SomeType> stack;
11
+
7 12
     public MyStack() {
8
-        throw new UnsupportedOperationException("Method not yet implemented");
13
+        stack = new Stack<>();
9 14
     }
10 15
 
11 16
     public Boolean isEmpty() {
12
-        return null;
17
+        return stack.empty();
13 18
     }
14 19
 
15 20
     public void push(SomeType i) {
21
+        stack.push(i);
16 22
     }
17 23
 
18 24
     public SomeType peek() {
19
-        throw new UnsupportedOperationException("Method not yet implemented");
25
+        if(stack.empty()) {
26
+            return null;
27
+        }
28
+        return stack.peek();
20 29
     }
21 30
 
22 31
     public SomeType pop() {
23
-        return null;
32
+        return stack.pop();
33
+    }
34
+
35
+    @Override
36
+    public Iterator iterator() {
37
+        return stack.iterator();
24 38
     }
25 39
 }

+ 43
- 5
src/main/java/rocks/zipcode/io/quiz4/generics/SortedGroup.java Просмотреть файл

@@ -1,18 +1,56 @@
1 1
 package rocks.zipcode.io.quiz4.generics;
2 2
 
3
+import java.awt.*;
4
+import java.util.ArrayList;
5
+import java.util.Iterator;
6
+import java.util.LinkedList;
7
+
3 8
 /**
4 9
  * @author leon on 18/12/2018.
5 10
  */
6
-public class SortedGroup<Type> extends Group<Type> {
11
+public class SortedGroup<Type> implements GroupInterface {
12
+    LinkedList sortedList;
13
+
14
+    public SortedGroup() {
15
+        sortedList = new LinkedList<Type>();
16
+    }
17
+
18
+    public Integer indexOf(Type firstValue) {
19
+        return sortedList.indexOf(firstValue);
20
+    }
21
+
7 22
     @Override
8
-    public void insert(Type value) {
23
+    public Integer count() {
24
+        return sortedList.size();
9 25
     }
10 26
 
11 27
     @Override
12
-    public void delete(Type value) {
28
+    public Boolean has(Object valueToInsert) {
29
+        return sortedList.contains(valueToInsert);
13 30
     }
14 31
 
15
-    public Integer indexOf(Type firstValue) {
16
-        return null;
32
+    @Override
33
+    public Object fetch(int indexOfValue) {
34
+        return sortedList.get(indexOfValue);
35
+    }
36
+
37
+    @Override
38
+    public void insert(Object string) {
39
+        sortedList.add(string);
40
+    }
41
+
42
+    @Override
43
+    public void delete(Object valueToInsert) {
44
+        sortedList.remove(valueToInsert);
45
+    }
46
+
47
+    @Override
48
+    public void clear() {
49
+        sortedList.clear();
50
+    }
51
+
52
+    @Override
53
+    public Iterator iterator() {
54
+        return sortedList.iterator();
17 55
     }
18 56
 }

+ 11
- 1
src/main/java/rocks/zipcode/io/quiz4/objectorientation/Student.java Просмотреть файл

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