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

Finally learned lab :) #93

Open
wants to merge 4 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
3 changes: 3 additions & 0 deletions .idea/.gitignore

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.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.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.

11 changes: 11 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: 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>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<packaging>jar</packaging>

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

public enum Educator implements Teacher{
DOLIO(Instructors.getInstance().findById(101L)),
LEON(Instructors.getInstance().findById(102L)),
KRIS(Instructors.getInstance().findById(103L));

Instructor instructor;
Double timeWorked = 0.0;

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;
}


}
21 changes: 21 additions & 0 deletions src/main/java/io/zipcoder/interfaces/Instructor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.zipcoder.interfaces;

public class Instructor extends Person implements Teacher{

Instructor(Long id, String name) { //default person. super cuz instructor is subclass
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 studentLearners : learners){ // for each Learner in array learners
studentLearners.learn(numberOfHoursPerLearner); //each learner can learn in
//divided hours by each student
//in learners array.
}
}
}
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 final class Instructors extends People<Instructor>{

public static final Instructors INSTANCE = new Instructors();

private Instructors() {
this.add(new Instructor (101L, "Dolio"));
this.add(new Instructor (102L, "Leon"));
this.add(new Instructor (103L, "Kris"));

}

public static Instructors getInstance(){
return INSTANCE;
}

public Instructor[] toArray(){
return elementList.toArray(new Instructor[0]);
}


}
10 changes: 10 additions & 0 deletions src/main/java/io/zipcoder/interfaces/Learner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.zipcoder.interfaces;

public interface Learner {

public void learn(double numberOfHours);

public Double getTotalStudyTime();

}

Loading