|
@@ -3,7 +3,7 @@
|
3
|
3
|
* **Objective** - to implement a `ZipCodeWilmington` _singleton_ which _mediates_ a _composite_ `Students` and `Instructors` reference.
|
4
|
4
|
|
5
|
5
|
|
6
|
|
-# Part 1.1 - Create `Person` Class
|
|
6
|
+### Part 1.1 - Create `Person` Class
|
7
|
7
|
* Create a `Person` class.
|
8
|
8
|
* The class should declare a `final` field named `id` of type `long`.
|
9
|
9
|
* `Person` constructor should have a parameter of type `long` which sets the `id` field to the respective value.
|
|
@@ -12,14 +12,14 @@
|
12
|
12
|
* The class should define a `setName()` method which sets the `Person` object's `name` field.
|
13
|
13
|
|
14
|
14
|
-
|
15
|
|
-# Part 1.0 - Test `Person`
|
|
15
|
+### Part 1.0 - Test `Person`
|
16
|
16
|
* Create a `TestPerson` class.
|
17
|
17
|
* Create a `testConstructor` method which ensures that a `Person` object's `id` field is being set upon construction.
|
18
|
18
|
* Create a `testSetName` method which ensures that a `Person` object's `name` variable is being set by invoking the `.setName` method.
|
19
|
19
|
* Create a `testConstructor` method which ensures that a `Person` object's `name` variable is being set by invoking the `Person` constructor.
|
20
|
20
|
|
21
|
21
|
-
|
22
|
|
-# Part 2.0 - Create `Learner` Interface
|
|
22
|
+### Part 2.0 - Create `Learner` Interface
|
23
|
23
|
* Create a `Learner` interface.
|
24
|
24
|
* `Learner` should declare one method signature:
|
25
|
25
|
* Method name: `learn`
|
|
@@ -27,7 +27,7 @@
|
27
|
27
|
* Method return-type: `void`
|
28
|
28
|
|
29
|
29
|
-
|
30
|
|
-# Part 3.1 - Create `Student` Class
|
|
30
|
+### Part 3.1 - Create `Student` Class
|
31
|
31
|
* Create a `Student` class such that:
|
32
|
32
|
* `Student` is a subclass of `Person`
|
33
|
33
|
* `Student` implements the `Learner` interface
|
|
@@ -37,14 +37,14 @@
|
37
|
37
|
|
38
|
38
|
|
39
|
39
|
-
|
40
|
|
-# Part 3.0 - Test `Student`
|
|
40
|
+### Part 3.0 - Test `Student`
|
41
|
41
|
* Create a `TestStudent` class.
|
42
|
42
|
* Create a `testImplementation` method that asserts that a `Student` is an `instanceof` a `Learner`.
|
43
|
43
|
* Create a `testInheritance` method that asserts that a `Student` is an `instanceof` a `Person`.
|
44
|
44
|
* Create a `testLearn` method that ensures a `Student`'s `totalStudyTime` instance variable is incremented by the specified `numberOfHours` by invoking the `.learn` method.
|
45
|
45
|
|
46
|
46
|
-
|
47
|
|
-# Part 4.0 - Create `Teacher` Interface
|
|
47
|
+### Part 4.0 - Create `Teacher` Interface
|
48
|
48
|
* Create a `Teacher` interface.
|
49
|
49
|
* `Teacher` should declare a `teach` method signature:
|
50
|
50
|
* Method name: `teach`
|
|
@@ -62,7 +62,7 @@
|
62
|
62
|
|
63
|
63
|
|
64
|
64
|
-
|
65
|
|
-# Part 5.1 - Create `Instructor` Class
|
|
65
|
+### Part 5.1 - Create `Instructor` Class
|
66
|
66
|
* Create an `Instructor` class such that:
|
67
|
67
|
* `Instructor` is a subclass of `Person`
|
68
|
68
|
* `Instructor` implements the `Teacher` interface
|
|
@@ -72,7 +72,7 @@
|
72
|
72
|
* `double numberOfHoursPerStudent = numberOfHours / students.length;`
|
73
|
73
|
|
74
|
74
|
-
|
75
|
|
-# Part 5.0 - Test `Instructor`
|
|
75
|
+### Part 5.0 - Test `Instructor`
|
76
|
76
|
* Create a `TestInstructor` class.
|
77
|
77
|
* Create a `testImplementation` method that asserts that an `Instructor` is an `instanceof` a `Teacher`.
|
78
|
78
|
* Create a `testInheritance` method that asserts that a `Instructor` is an `instanceof` a `Person`.
|
|
@@ -81,7 +81,7 @@
|
81
|
81
|
|
82
|
82
|
|
83
|
83
|
-
|
84
|
|
-# Part 6.1 - Create `People` class
|
|
84
|
+### Part 6.1 - Create `People` class
|
85
|
85
|
* Create a `People` class.
|
86
|
86
|
* The class should instantiate an `ArrayList` field of `Person` objects named `personList`.
|
87
|
87
|
* The class should define a method named `add` which adds a `Person` to the `personList`.
|
|
@@ -93,7 +93,7 @@
|
93
|
93
|
* The class should define a named `removeAll` which clears our `personList` field.
|
94
|
94
|
|
95
|
95
|
-
|
96
|
|
-# Part 6.0 - Test `People`
|
|
96
|
+### Part 6.0 - Test `People`
|
97
|
97
|
* Create a `TestPeople` class.
|
98
|
98
|
* Create a `testAdd` method which ensures that our `personList` in our `People` class populated with respective `Student` objects following invokation of the `addStudent` method.
|
99
|
99
|
* Create a `testRemove` method which ensures that the `personList` in a `People` object is **depopulated** with a respective `Person` object following the invokation of the `remove` method.
|
|
@@ -101,7 +101,7 @@
|
101
|
101
|
|
102
|
102
|
|
103
|
103
|
-
|
104
|
|
-# Part 7.1 - Create `Students` singleton
|
|
104
|
+### Part 7.1 - Create `Students` singleton
|
105
|
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).
|
106
|
106
|
* Create a `Students` class.
|
107
|
107
|
* The class should be an _unextendable_ subclass of the `People` class.
|
|
@@ -113,18 +113,18 @@
|
113
|
113
|
|
114
|
114
|
|
115
|
115
|
-
|
116
|
|
-# Part 7.0 - Test `Students` singleton
|
|
116
|
+### Part 7.0 - Test `Students` singleton
|
117
|
117
|
* Create a `TestStudents` class.
|
118
|
118
|
* Create a `test` method which ensures that each of the students in your current cohort are in your `Students` singleton.
|
119
|
119
|
|
120
|
120
|
-
|
121
|
|
-# Part 7.2 - Create `Instructors` singleton
|
|
121
|
+### Part 7.2 - Create `Instructors` singleton
|
122
|
122
|
* Use `Part 7.0` and `Part 7.1` as a reference.
|
123
|
123
|
* Create a `Instructors` singleton which represents the set of instructors at ZipCodeWilmington.
|
124
|
124
|
* Create a `TestInstructors` class.
|
125
|
125
|
|
126
|
126
|
|
127
|
|
-# Part 8.1 - Create `ZipCodeWilmington` Class
|
|
127
|
+### Part 8.1 - Create `ZipCodeWilmington` Class
|
128
|
128
|
* Use `Part 7` as a reference.
|
129
|
129
|
* Create a `ZipCodeWilmington` singleton.
|
130
|
130
|
* The class should declare a field that references the instance of `Students` called `students`.
|
|
@@ -146,11 +146,11 @@
|
146
|
146
|
|
147
|
147
|
|
148
|
148
|
-
|
149
|
|
-# Notice the Design Flaw - Odd Casting Issues
|
|
149
|
+### Notice the Design Flaw - Odd Casting Issues
|
150
|
150
|
* You may have noticed that the `findById`, and `hostLecture` methods require an intermediate [casting trick](https://stackoverflow.com/questions/5289393/casting-variables-in-java).
|
151
|
151
|
* To remedy this issue, we can _generify_ the `People` class.
|
152
|
152
|
|
153
|
|
-# Part 9.1 - Modify `People` class
|
|
153
|
+### Part 9.1 - Modify `People` class
|
154
|
154
|
* [Parameterize](https://stackoverflow.com/questions/12551674/what-is-meant-by-parameterized-type) the `People` signature to enfore that it is a container for objects of type `E` such that `E` is a subclass of `Person`.
|
155
|
155
|
* Modify `people` field to enforce that is a container of objects of type `E`.
|
156
|
156
|
* Modify the `add` method to ensure that it handles object of type `E`.
|
|
@@ -173,21 +173,21 @@
|
173
|
173
|
|
174
|
174
|
|
175
|
175
|
-
|
176
|
|
-# Notice the Design Flaw - Non-Intuitive Orientation
|
|
176
|
+### Notice the Design Flaw - Non-Intuitive Orientation
|
177
|
177
|
* You may have notice that `findById` makes it difficult to intuitively identify _which_ `Person` object is being returned.<br>
|
178
|
178
|
Additionally, it's challengaing to ensure **every** `Person` instance has a unique ID amongst its respective `People` subclass.<br>
|
179
|
179
|
To remedy this issue, we redesign and refactor.
|
180
|
180
|
|
181
|
|
-# Part 9.1 - Create `Educator` enum
|
|
181
|
+### Part 9.1 - Create `Educator` enum
|
182
|
182
|
* Create an enum named `Educator`.
|
183
|
183
|
* The enum should implement `Teacher`.
|
184
|
184
|
* The enum should have an enumeration for each of the instructors represented in the `Instructors` class.
|
185
|
185
|
* The enum should have an _empty nullary constructor_.
|
186
|
186
|
|
187
|
|
-# Part 9.0 - Test `Educator`
|
|
187
|
+### Part 9.0 - Test `Educator`
|
188
|
188
|
* Use `Part 5` as a reference.
|
189
|
189
|
|
190
|
|
-# Part 10.1 - Modify `Instructor` Class
|
|
190
|
+### Part 10.1 - Modify `Instructor` Class
|
191
|
191
|
* Annotate the constructor with `@Deprecated`.
|
192
|
192
|
* This constructor should be commented with `//TODO - Remove dependencies`
|
193
|
193
|
* Create a constructor in the `Instructor` class which uses `Educator educator` parameter to set a final `educator` field.
|
|
@@ -195,6 +195,6 @@ To remedy this issue, we redesign and refactor.
|
195
|
195
|
* Remove any calls being made to the deprecated construcor.
|
196
|
196
|
* Remove the deprecated constructor from the class.
|
197
|
197
|
|
198
|
|
-# Part 10.0 - Test `Instructor`
|
|
198
|
+### Part 10.0 - Test `Instructor`
|
199
|
199
|
* Refactor `TestInstructor` to support the newly created `Instructor` constructor.
|
200
|
200
|
* Ensure the tests were not affected by the refactoring.
|