Skip to content

Done #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Done #74

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .idea/$PRODUCT_WORKSPACE_FILE$

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__junit_junit_4_12.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Leon's Lengthy Learner Lab
* **Objective** - to implement a `ZipCodeWilmington` class which _mediates_ a _composite_ `Students` and `Instructors` _singleton_ reference.
* **Objective** - to implement a `ZipCodeWilmington` class which _mediates_ a _composite_ `io.zipcoder.interfaces.Students` and `Instructors` _singleton_ reference.
* **Purpose** - to demonstrate the use of
* [interfaces](https://stackoverflow.com/questions/1321122/what-is-an-interface-in-java)
* [abstract classes](https://stackoverflow.com/questions/1320745/abstract-class-in-java)
Expand Down Expand Up @@ -111,21 +111,21 @@


-
### Part 7.1 - Create `Students` singleton
### Part 7.1 - Create `io.zipcoder.interfaces.Students` singleton
* **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).
* Create a `Students` class.
* Create a `io.zipcoder.interfaces.Students` class.
* The class should be an _unextendable_ subclass of the `People` class.
* The class should _statically instantiate_ a `final` field named `INSTANCE` of type `Students`.
* The class should _statically instantiate_ a `final` field named `INSTANCE` of type `io.zipcoder.interfaces.Students`.
* The class should define a _private nullary constructor_ which populates the `INSTANCE` field with respective `Student` representations of your colleagues.
* Each student should have a _relatively_ unique `id` field.
* The class should define a `getInstance` method which returns the `INSTANCE` field.



-
### Part 7.0 - Test `Students` singleton
### Part 7.0 - Test `io.zipcoder.interfaces.Students` singleton
* Create a `TestStudents` class.
* Create a `test` method which ensures that each of the students in your current cohort are in your `Students` singleton.
* Create a `test` method which ensures that each of the students in your current cohort are in your `io.zipcoder.interfaces.Students` singleton.



Expand All @@ -139,7 +139,7 @@
-
### Part 9.1 - Create `ZipCodeWilmington` Class
* Create a `ZipCodeWilmington` singleton.
* The class should declare a field that references the instance of `Students` called `students`.
* The class should declare a field that references the instance of `io.zipcoder.interfaces.Students` called `students`.
* The class should declare a field that references the instance of `Instructors` called `instructors`.
* The class should define a method `hostLecture` which makes use of a `Teacher teacher, double numberOfHours` parameter to host a `lecture` to the composite `personList` field in the `students` reference.
* 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 `personList` field in the `cohort` reference.
Expand Down Expand Up @@ -176,7 +176,7 @@

-
### Part 10.2 - Modify `People` subclasses
* Modify the `Students` class signature to ensure that it is a subclass of `People` of parameterized type `Student`.
* Modify the `io.zipcoder.interfaces.Students` class signature to ensure that it is a subclass of `People` of parameterized type `Student`.
* Modify the `Instructors` class signature to ensure that it is a subclass of `People` of parameterized type `Instructor`.
* Provide concrete implementations of the `getArray` method in each of these classes.

Expand Down
16 changes: 16 additions & 0 deletions interfaces-1.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
25 changes: 25 additions & 0 deletions src/main/java/io/zipcoder/interfaces/Educator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.zipcoder.interfaces;

public enum Educator implements Teacher {

ONE(new Instructor(2323L, "BIP")), BOOP(new Instructor(3232L, "BOOP"));

Instructor instructor;
Double timeWorked = 0D;

Educator(Instructor instructor) {
this.instructor = instructor;
}

@Override
public void teach(Learner learner, Double numberOfHours) {
this.instructor.teach(learner,numberOfHours);
this.timeWorked += numberOfHours;
}

@Override
public void lecture(Learner[] learners, Double numberOfHours) {
this.instructor.lecture(learners, numberOfHours);
this.timeWorked += numberOfHours;
}
}
18 changes: 18 additions & 0 deletions src/main/java/io/zipcoder/interfaces/Instructor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.zipcoder.interfaces;

public class Instructor extends Person implements Teacher {
public Instructor(Long id, String name) {
super(id, name);
}

public void teach(Learner learner, Double numberOfHours) {
learner.learn(numberOfHours);
}

public void lecture(Learner[] learners, Double numberOfHours) {
Double numberOfHoursPerLearner = numberOfHours / learners.length;
for(Learner l : learners){
l.learn(numberOfHoursPerLearner);
}
}
}
23 changes: 23 additions & 0 deletions src/main/java/io/zipcoder/interfaces/Instructors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.zipcoder.interfaces;

public class Instructors extends People<Instructor> {

public static final Instructors INSTANCE = new Instructors();

private Instructors(){
Instructor instructor1 = new Instructor(2323L, "Boop");
Instructor instructor2 = new Instructor(3232L, "Bip");
personList.add(instructor1);
personList.add(instructor2);

}

public static Instructors getInstance(){
return INSTANCE;
}

@Override
public Instructor[] toArray() {
return personList.toArray(new Instructor[personList.size()]);
}
}
Loading