|
@@ -1,5 +1,6 @@
|
1
|
1
|
# Student, Instructor, Classroom
|
2
|
2
|
* **Purpose** - to demonstrate the use of [Java interfaces](http://tutorials.jenkov.com/java/interfaces.html)
|
|
3
|
+* **Objective** - to implement a `ZipCodeWilmington` _singleton_ which _mediates_ a _composite_ `Students` and `Instructors` reference.
|
3
|
4
|
|
4
|
5
|
|
5
|
6
|
# Part 1.1 - Create `Person` Class
|
|
@@ -100,39 +101,43 @@
|
100
|
101
|
|
101
|
102
|
|
102
|
103
|
-
|
103
|
|
-# Part 7.1 - Create `MyCohort` singleton
|
|
104
|
+# Part 7.1 - Create `Students` singleton
|
104
|
105
|
* **Note:** The creation of this class will demonstrate an implementation of [singleton design pattern](https://www.journaldev.com/1377/java-singleton-design-pattern-best-practices-examples#eager-initialization).
|
105
|
|
-* Create a `MyCohort` class.
|
106
|
|
- * The class should be a subclass of the `People` class.
|
107
|
|
- * The class should _statically instantiate_ a `final` field named `INSTANCE` of type `MyCohort`.
|
108
|
|
- * The class should define a _private constructor_ which populates the `INSTANCE` field with respective `Student` representations of your colleagues.
|
109
|
|
- * Each student should have a unique `id` field.
|
|
106
|
+* Create a `Students` class.
|
|
107
|
+ * The class should be an _unextendable_ subclass of the `People` class.
|
|
108
|
+ * The class should _statically instantiate_ a `final` field named `INSTANCE` of type `Students`.
|
|
109
|
+ * The class should define a _private nullary constructor_ which populates the `INSTANCE` field with respective `Student` representations of your colleagues.
|
|
110
|
+ * Each student should have a _relatively_ unique `id` field.
|
110
|
111
|
* The class should define a `getInstance` method which returns the `INSTANCE` field.
|
111
|
112
|
|
112
|
113
|
|
113
|
114
|
|
114
|
115
|
-
|
115
|
|
-# Part 7.0 - Test `MyCohort` singleton
|
116
|
|
-* Create a `TestMyCohort` class.
|
117
|
|
- * Create a `test` method which ensures that each of the students in your current cohort are in your `MyCohort` singleton.
|
|
116
|
+# Part 7.0 - Test `Students` singleton
|
|
117
|
+* Create a `TestStudents` class.
|
|
118
|
+ * Create a `test` method which ensures that each of the students in your current cohort are in your `Students` singleton.
|
118
|
119
|
|
119
|
120
|
-
|
120
|
|
-# Part 7.2 - Create `ZipCodeInstructors` singleton
|
|
121
|
+# Part 7.2 - Create `Instructors` singleton
|
121
|
122
|
* Use `Part 7.0` and `Part 7.1` as a reference.
|
122
|
|
-* Create a `ZipCodeInstructors` singleton which represents the set of instructors at ZipCodeWilmington.
|
123
|
|
-* Create a `TestZipCodeInstructors` class.
|
|
123
|
+* Create a `Instructors` singleton which represents the set of instructors at ZipCodeWilmington.
|
|
124
|
+* Create a `TestInstructors` class.
|
124
|
125
|
|
125
|
126
|
|
126
|
|
-
|
127
|
|
--
|
128
|
127
|
# Part 8.1 - Create `ZipCodeWilmington` Class
|
129
|
128
|
* Use `Part 7` as a reference.
|
130
|
129
|
* Create a `ZipCodeWilmington` singleton.
|
131
|
|
- * The class should declare a field that references `MyCohort` called `cohort`.
|
132
|
|
- * The class should declare a field that references `ZipCodeInstructors` called `instructors`.
|
|
130
|
+ * The class should declare a field that references the instance of `Students` called `students`.
|
|
131
|
+ * The class should declare a field that references the instance of `Instructors` called `instructors`.
|
133
|
132
|
* The class should define a method `hostLecture` which makes use of a `long id, double numberOfHours` parameter to identify a respective `Instructor` to host a `lecture` to the composite `people` field in the `cohort` reference.
|
134
|
133
|
|
135
|
134
|
-
|
136
|
135
|
# Part 8.0 - Test `ZipCodeWilmington`
|
137
|
136
|
* Create a `TestZipCodeWilmington` class.
|
138
|
137
|
* Create a `testHostLecture` method which ensures that each of the `Student`'s `totalStudyTime` instance variable is incremented by the specified `numberOfHours` upon invoking the `.hostLecture` method.
|
|
138
|
+
|
|
139
|
+-
|
|
140
|
+# Notice the Design Flaw
|
|
141
|
+* You may have notice that `findById` makes it difficult to intuitively identify _which_ `Person` object is being returned.<br>
|
|
142
|
+Additionally, it's challengaing to ensure **every** `Person` instance has a unique ID amongst its respective `People` subclass.<br>
|
|
143
|
+To remedy this issue, we redesign and refactor. Visit the [enum microlab]()
|