Skip to content
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

Complete #78

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 19 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.

32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,18 @@
* 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 `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.
* The class should define a method `getStudyMap` which returns a <u>new instance</u> of a _mapping_ from `Student` objects to `Double` objects, representative of each respective student's `totalStudyTime`.
* 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.
* The class should define a method `getStudyMap` which returns a <u>new instance</u> of a _mapping_ from `Student` objects
to `Double` objects, representative of each respective student's `totalStudyTime`.

-
### Part 9.0 - Test `ZipCodeWilmington`
* Create a `TestZipCodeWilmington` class.
* 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.
* 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.



Expand All @@ -171,7 +175,7 @@
* Modify `people` field to enforce that is a container of objects of type `E`.
* Modify the `add` method to ensure that it handles object of type `E`.
* Modify the `findById` method to ensure that it returns an object of type `E`.
* Modify the `getArray` method signature by declaring it `abstract` of return tyoe `E`.
* Modify the `getArray` method signature by declaring it `abstract` of return type `E`.
* An abstract method is a subclass's contractual agreement to the deferment of an implementation of a respective method.

-
Expand All @@ -192,19 +196,25 @@




-
# Notice the Design Flaw - Non-Intuitive Orientation
* You may have noticed that `findById` makes it difficult to intuitively identify _which_ `Person` object is being returned. To remedy this issue, we can make use of an `enum` which manipulates a composite `instructor` object.
* You may have noticed that `findById` makes it difficult to intuitively identify _which_
`Person` object is being returned. To remedy this issue, we can make use of an `enum` which
manipulates a composite `instructor` object.

-
### Part 11.1 - Create `Educator` enum
* Create an enum named `Educator`.
* The enum should implement `Teacher`.
* The enum should have an enumeration for each of the instructors represented in the `Instructors` class.
* Upon construction each enumeration of the enum should instantiate a respective `Instructor` and assign it to a final `instructor` field upon construction. The `instructor` should be added to the `Instructors` singleton.
* Calls to the `teach` and `lecture` method should be deferred to the composite `instructor` reference.
* The enum should have a `double timeWorked` field which keeps track of the hours that the `Educator` has taught.
* The enum should have an enumeration for each of the instructors represented in the
`Instructors` class.
* Upon construction each enumeration of the enum should instantiate a respective
`Instructor` and assign it to a final `instructor` field upon construction. The
`instructor` should be added to the `Instructors` singleton.
* Calls to the `teach` and `lecture` method should be deferred to the composite
`instructor` reference.
* The enum should have a `double timeWorked` field which keeps track of the hours
that the `Educator` has taught.

-
### Part 11.0 - Test `Educator`
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>
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@
<groupId>io.zipcoder</groupId>
<artifactId>interfaces-1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>6</source>
<target>6</target>
</configuration>
</plugin>
</plugins>
</build>
<packaging>jar</packaging>

<name>interfaces-1</name>
<url>http://maven.apache.org</url>
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/io/zipcoder/interfaces/Educator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.zipcoder.interfaces;

public enum Educator implements Teacher{

KRIS(1, "Kris"), CHRIS(9, "Chris"), FROILAN(10, "Froilan"), DOLIO(11, "Dolio"), ROBERTO(6, "Roberto");

private long id;
private String name;
private double timeWorked;

Educator(long id, String name) {
this.id = id;
this.name = name;
//Instructors.getInstance().add(new Instructor(this.id, this.name));
}

public long getId() {
return id;
}

public String getName() {
return name;
}

public double getTimeWorked() {
return timeWorked;
}

public void teach(Learner learner, double numberOfHours) {
Instructors.getInstance().findById(this.id).teach(learner, numberOfHours);
this.timeWorked += numberOfHours;
}

public void lecture(Learner[] learners, double numberOfHours) {
Instructors.getInstance().findById(this.id).lecture(learners, numberOfHours);
this.timeWorked += numberOfHours;
}

}
Loading