소스 검색

Person

Learner
Student
Teacher
Instructor
People
Students
Instructors
Classroom
Nick Satinover 6 년 전
부모
커밋
05cf73c866

+ 16
- 0
demo/src/main/java/com/example/demo/Classroom.java 파일 보기

@@ -0,0 +1,16 @@
1
+package com.example.demo;
2
+
3
+public class Classroom {
4
+    private Instructors instructors;
5
+    private Students students;
6
+
7
+    Classroom(Instructors instructors, Students students){
8
+        this.instructors = instructors;
9
+        this.students = students;
10
+    }
11
+
12
+    public void hostLecture(Teacher teacher, double numberOfHours){
13
+        teacher.lecture(students, numberOfHours);
14
+    }
15
+
16
+}

+ 0
- 8
demo/src/main/java/com/example/demo/Instructor.java 파일 보기

@@ -20,7 +20,6 @@ public class Instructor extends Person implements Teacher{
20 20
 
21 21
     @Override
22 22
     public void lecture(Iterable<? extends Learner> learners, double numberOfHours) {
23
-        // int numberOfLearners = lengthOfIterable(learners);
24 23
         long numberOfLearners = learners
25 24
                 .spliterator()
26 25
                 .getExactSizeIfKnown();
@@ -29,11 +28,4 @@ public class Instructor extends Person implements Teacher{
29 28
         learners.forEach(o -> o.learn(numberOfHoursPerLearner));
30 29
     }
31 30
 
32
-//    private int lengthOfIterable(Iterable iterable){
33
-//        int counter = 0;
34
-//        for (Object o: iterable) {
35
-//            counter++;
36
-//        }
37
-//        return counter;
38
-//    }
39 31
 }

+ 27
- 0
demo/src/main/java/com/example/demo/Instructors.java 파일 보기

@@ -0,0 +1,27 @@
1
+package com.example.demo;
2
+
3
+import java.util.Iterator;
4
+import java.util.List;
5
+import java.util.Spliterator;
6
+import java.util.function.Consumer;
7
+
8
+public class Instructors<Instructor> extends People {
9
+    Instructors(List instructorList) {
10
+        super(instructorList);
11
+    }
12
+
13
+    @Override
14
+    public Iterator iterator() {
15
+        return null;
16
+    }
17
+
18
+    @Override
19
+    public void forEach(Consumer action) {
20
+
21
+    }
22
+
23
+    @Override
24
+    public Spliterator spliterator() {
25
+        return null;
26
+    }
27
+}

+ 5
- 4
demo/src/main/java/com/example/demo/People.java 파일 보기

@@ -1,12 +1,13 @@
1 1
 package com.example.demo;
2 2
 
3 3
 import java.util.ArrayList;
4
+import java.util.List;
4 5
 
5 6
 public abstract class People<PersonType extends Person> implements Iterable<PersonType> {
6
-    ArrayList<PersonType> personList;
7
+    List<PersonType> personList;
7 8
 
8
-    People(){
9
-        personList = new ArrayList<>();
9
+    People(List<PersonType> personTypeList){
10
+        personList = personTypeList;
10 11
     }
11 12
 
12 13
     public void add(PersonType pt){
@@ -41,7 +42,7 @@ public abstract class People<PersonType extends Person> implements Iterable<Pers
41 42
         return null;
42 43
     }
43 44
 
44
-    public ArrayList<PersonType> findAll(){
45
+    public List<PersonType> findAll(){
45 46
         return personList;
46 47
     }
47 48
 }

+ 11
- 4
demo/src/main/java/com/example/demo/Students.java 파일 보기

@@ -1,22 +1,29 @@
1 1
 package com.example.demo;
2 2
 
3
+import java.util.ArrayList;
3 4
 import java.util.Iterator;
5
+import java.util.List;
4 6
 import java.util.Spliterator;
5 7
 import java.util.function.Consumer;
6 8
 
7
-public class Students extends People<Person> {
9
+public class Students<Student> extends People {
10
+
11
+    public Students(List<Student> students) {
12
+        super(students);
13
+    }
14
+
8 15
     @Override
9
-    public Iterator<Person> iterator() {
16
+    public Iterator iterator() {
10 17
         return null;
11 18
     }
12 19
 
13 20
     @Override
14
-    public void forEach(Consumer<? super Person> action) {
21
+    public void forEach(Consumer action) {
15 22
 
16 23
     }
17 24
 
18 25
     @Override
19
-    public Spliterator<Person> spliterator() {
26
+    public Spliterator spliterator() {
20 27
         return null;
21 28
     }
22 29
 }