Sfoglia il codice sorgente

SpringBoot is working

Nick Satinover 6 anni fa
parent
commit
4857f0c1fb

+ 26
- 9
demo/src/main/java/com/example/demo/Alumni.java Vedi File

@@ -7,14 +7,14 @@ import org.springframework.stereotype.Component;
7 7
 import javax.annotation.PostConstruct;
8 8
 
9 9
 @Component
10
-@DependsOn("StudentsConfig")
10
+// @DependsOn("StudentsConfig")
11 11
 public class Alumni {
12 12
 
13 13
     private Students alumni;
14 14
     private Instructors instructors;
15 15
 
16
-    Alumni(@Autowired Instructors instructors, @Autowired StudentsConfig studentsConfig){
17
-        this.instructors = instructors;
16
+    Alumni(@Autowired InstructorsConfig instructorsConfig, @Autowired StudentsConfig studentsConfig){
17
+        this.instructors = instructorsConfig.tcUsaInstructors();
18 18
         this.alumni = studentsConfig.previousStudents();
19 19
     }
20 20
 
@@ -27,13 +27,30 @@ public class Alumni {
27 27
     }
28 28
 
29 29
     @PostConstruct
30
-    public void executeBootcamp(){
31
-        int numberOfHoursPerInstructor = 1200 / instructors.personList.size();
32
-        for (Instructor i: instructors) {
33
-            i.lecture(alumni, numberOfHoursPerInstructor);
30
+    public void executeBootcamp (){
31
+        try {
32
+            int numOfInstructors = instructors.personList.size();
33
+            int numberOfHoursPerInstructor = 1200 / numOfInstructors;
34
+//            for (Instructor i : instructors) {
35
+//                i.lecture(alumni, numberOfHoursPerInstructor);
36
+//            }
37
+            for (int i = 0; i < numOfInstructors; i++){
38
+                instructors.personList.get(i)
39
+                    .lecture(alumni, numberOfHoursPerInstructor);
40
+            }
41
+        } catch (ArithmeticException e){
42
+            throw new ArithmeticException("Cannot divide by zero");
34 43
         }
35
-
36 44
     }
37 45
 
38
-
39 46
 }
47
+//    public void executeBootcamp (){
48
+//        if (instructors.personList.size() == 0){
49
+//            throw new ArithmeticException("Cannot divide by zero");
50
+//        } else {
51
+//            int numberOfHoursPerInstructor = 1200 / instructors.personList.size();
52
+//            for (Instructor i : instructors) {
53
+//                i.lecture(alumni, numberOfHoursPerInstructor);
54
+//            }
55
+//        }
56
+//    }

+ 1
- 1
demo/src/main/java/com/example/demo/ClassroomConfig.java Vedi File

@@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration;
8 8
 import org.springframework.context.annotation.DependsOn;
9 9
 
10 10
 @Configuration
11
-@DependsOn({"students", "previousStudents", "tcUsaInstructors", "tcUkInstructors", "instructors"})
11
+// @DependsOn({"students", "previousStudents", "tcUsaInstructors", "tcUkInstructors", "instructors"})
12 12
 public class ClassroomConfig {
13 13
 
14 14
     @Bean(name = "currentCohort")

+ 2
- 2
demo/src/main/java/com/example/demo/Students.java Vedi File

@@ -17,7 +17,7 @@ public class Students extends People<Student> {
17 17
 
18 18
     @Override
19 19
     public Iterator iterator() {
20
-        return null;
20
+        return this.personList.iterator();
21 21
     }
22 22
 
23 23
     @Override
@@ -27,7 +27,7 @@ public class Students extends People<Student> {
27 27
 
28 28
     @Override
29 29
     public Spliterator spliterator() {
30
-        return null;
30
+        return this.personList.spliterator();
31 31
     }
32 32
 
33 33
 

+ 1
- 1
demo/src/main/java/com/example/demo/StudentsConfig.java Vedi File

@@ -10,7 +10,7 @@ import java.util.ArrayList;
10 10
 public class StudentsConfig {
11 11
 
12 12
     @Bean(name = "students")
13
-    //@Qualifier("tudents")
13
+    //@Qualifier("students")
14 14
     public Students students(){
15 15
         ArrayList<Student> currentStudents = new ArrayList<>();
16 16