diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..0e40fe8f
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+
+# Default ignored files
+/workspace.xml
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 00000000..a0f2c3a1
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+interfaces-1
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 00000000..fdc60f4f
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 00000000..b26911bd
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml
new file mode 100644
index 00000000..d4110417
--- /dev/null
+++ b/.idea/libraries/Maven__junit_junit_4_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
new file mode 100644
index 00000000..f58bbc11
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..d30d09e2
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..711b3a53
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 00000000..e96534fb
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/interfaces-1.iml b/interfaces-1.iml
new file mode 100644
index 00000000..0ddf51c1
--- /dev/null
+++ b/interfaces-1.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/io/zipcoder/interfaces/Educator.java b/src/main/java/io/zipcoder/interfaces/Educator.java
new file mode 100644
index 00000000..7c991537
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Educator.java
@@ -0,0 +1,26 @@
+package io.zipcoder.interfaces;
+
+public enum Educator implements Teacher {
+ ZAN(0,"Zan"), ISANNOYING(1, "is Annoying");
+
+ public double timeWorked;
+ public final Instructor instructor;
+
+ Educator(long id, String name) {
+ instructor = new Instructor(id, name);
+ }
+
+ public void teach(Learner learner, double numberOfHours) {
+ this.timeWorked += numberOfHours;
+ instructor.teach(learner,numberOfHours);
+ }
+
+ public void lecture(Learner[] learners, double numberOfHours) {
+ this.timeWorked += numberOfHours;
+ instructor.lecture(learners,numberOfHours);
+ }
+
+ public double getTimeWorked(){
+ return timeWorked;
+ }
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Instructor.java b/src/main/java/io/zipcoder/interfaces/Instructor.java
new file mode 100644
index 00000000..1fbd55d2
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Instructor.java
@@ -0,0 +1,22 @@
+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 (int i = 0; i < learners.length; i++) {
+ learners[i].learn(numberOfHoursPerLearner);
+ }
+ }
+
+
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Instructors.java b/src/main/java/io/zipcoder/interfaces/Instructors.java
new file mode 100644
index 00000000..bce6775d
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Instructors.java
@@ -0,0 +1,32 @@
+package io.zipcoder.interfaces;
+
+import java.util.ArrayList;
+
+public final class Instructors extends People{
+
+ private static final Instructors INSTANCE = new Instructors();
+
+ private Instructors(){
+ ArrayList instructorZan = new ArrayList();
+ instructorZan.add(0,"ZANN");
+ instructorZan.add(1,"isAnnoying");
+
+ for (int i = 0; i < instructorZan.size(); i++) {
+ super.add(new Instructor(i,instructorZan.get(i)));
+ }
+ }
+
+ public Instructor[] toArray() {
+ return personList.toArray(new Instructor[personList.size()]);
+ }
+
+ public static Instructors getInstance(){
+ if(INSTANCE != null){
+ return INSTANCE;
+ }
+ else{
+ return INSTANCE;
+ }
+ }
+
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Learner.java b/src/main/java/io/zipcoder/interfaces/Learner.java
new file mode 100644
index 00000000..123cc944
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Learner.java
@@ -0,0 +1,7 @@
+package io.zipcoder.interfaces;
+
+public interface Learner {
+ public void learn(double numberOfHours);
+
+ public Double getTotalStudyTime();
+}
diff --git a/src/main/java/io/zipcoder/interfaces/People.java b/src/main/java/io/zipcoder/interfaces/People.java
new file mode 100644
index 00000000..7ea9e7ec
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/People.java
@@ -0,0 +1,70 @@
+package io.zipcoder.interfaces;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public abstract class People {
+ ArrayList personList;
+ E person = null;
+// Person person = new Person(01, "Johnny");
+
+ public People(){
+ personList = new ArrayList();
+ }
+
+// public Iterator iterator(){
+// return personList.iterator();
+// }
+
+ public void add(E person){
+ personList.add(person);
+ }
+
+ public E findById(long id){
+ for (int i = 0; i < personList.size(); i++) {
+ if(personList.get(i).getId() == id){
+ return person;
+ }
+ }
+ return null;
+ }
+
+ public boolean contains(E person){
+ if(personList.contains(person)){
+ return true;
+ }
+ return false;
+ }
+
+ public void remove(E person){
+ personList.remove(person);
+ }
+
+ public void removeById(long id) {
+ for (int i = 0; i < personList.size(); i++) {
+ if (personList.get(i).getId() == id) {
+ personList.remove(i);
+ }
+ }
+ }
+
+ public void removeAll(){
+ personList.removeAll(personList);
+ }
+
+ public Integer count(){
+ return personList.size();
+ }
+
+ public abstract E[] toArray();
+
+// public String[] toArray(){
+// String[] newArr = personList.toArray(new String[0]);
+// return newArr;
+// }
+
+
+
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Person.java b/src/main/java/io/zipcoder/interfaces/Person.java
index fc6a3ffe..b4e3e1b9 100644
--- a/src/main/java/io/zipcoder/interfaces/Person.java
+++ b/src/main/java/io/zipcoder/interfaces/Person.java
@@ -1,5 +1,39 @@
package io.zipcoder.interfaces;
+import java.util.Objects;
+
public class Person {
+ final long id;
+ String name;
+
+ public Person(long id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+// @Override
+// public boolean equals(Object o) {
+// if (this == o) return true;
+// if (!(o instanceof Person)) return false;
+// Person person = (Person) o;
+// return getId() == person.getId() &&
+// getName().equals(person.getName());
+// }
+//
+//// @Override
+//// public int hashCode() {
+//// return Objects.hash(getId(), getName());
+//// }
+
+ public void setName(String name) {
+ this.name = name;
+ }
}
diff --git a/src/main/java/io/zipcoder/interfaces/Student.java b/src/main/java/io/zipcoder/interfaces/Student.java
new file mode 100644
index 00000000..f38f70ab
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Student.java
@@ -0,0 +1,18 @@
+package io.zipcoder.interfaces;
+
+public class Student extends Person implements Learner {
+ double totalStudyTime;
+
+ public Student(long id, String name) {
+ super(id, name);
+ }
+
+ public void learn(double numberOfHours){
+ totalStudyTime = numberOfHours + totalStudyTime;
+ }
+
+ public Double getTotalStudyTime(){
+ return totalStudyTime;
+ }
+
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Students.java b/src/main/java/io/zipcoder/interfaces/Students.java
new file mode 100644
index 00000000..5ab98eac
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Students.java
@@ -0,0 +1,24 @@
+package io.zipcoder.interfaces;
+
+public final class Students extends People{
+
+ private static final Students INSTANCE = new Students();
+
+ private Students(){
+ super.add(new Student(05, "Ban"));
+ super.add(new Student(06, "chod"));
+ }
+
+ public Student[] toArray() {
+ return personList.toArray(new Student[personList.size()]);
+ }
+
+ public static Students getInstance(){
+ if(INSTANCE != null){
+ return INSTANCE;
+ }
+ else{
+ return INSTANCE;
+ }
+ }
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Teacher.java b/src/main/java/io/zipcoder/interfaces/Teacher.java
new file mode 100644
index 00000000..9a67c19f
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Teacher.java
@@ -0,0 +1,8 @@
+package io.zipcoder.interfaces;
+
+public interface Teacher {
+
+ public void teach(Learner learner, double numberOfHours);
+
+ public void lecture(Learner[] learners, double numberOfHours);
+}
diff --git a/src/main/java/io/zipcoder/interfaces/ZipCodeWilmington.java b/src/main/java/io/zipcoder/interfaces/ZipCodeWilmington.java
new file mode 100644
index 00000000..6fb1d95c
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/ZipCodeWilmington.java
@@ -0,0 +1,34 @@
+package io.zipcoder.interfaces;
+
+public final class ZipCodeWilmington extends People{
+
+ private static final ZipCodeWilmington INSTANCE = new ZipCodeWilmington();
+ private static final Students students = Students.getInstance();
+ private static final Instructors instructors = Instructors.getInstance();
+
+ private ZipCodeWilmington(){
+
+ }
+
+ public void hostLecture(Teacher teacher, double numberOfHours){
+ teacher.lecture(students.toArray(),numberOfHours);
+ }
+
+ public void hostLecture(Long id, double numberOfHours){
+ Instructor instructor = instructors.findById(id);
+ instructor.lecture(students.toArray(),numberOfHours);
+ }
+
+ public static ZipCodeWilmington getInstance(){
+ if(INSTANCE != null){
+ return INSTANCE;
+ }
+ else{
+ return INSTANCE;
+ }
+ }
+
+ public Person[] toArray() {
+ return new Person[0];
+ }
+}
diff --git a/src/test/java/io/zipcoder/interfaces/TestEducator.java b/src/test/java/io/zipcoder/interfaces/TestEducator.java
new file mode 100644
index 00000000..60b2e1e1
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/TestEducator.java
@@ -0,0 +1,76 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestEducator {
+ Educator educator = Educator.ZAN;
+ Instructor instructor;
+ Student student;
+
+ @Before
+ public void testCon(){
+ instructor = new Instructor(11, "Zan");
+ student = new Student(01, "Johnny");
+ }
+
+ @Test
+ public void getTimeWorked(){
+ educator.teach(student, 5);
+
+ Double expected = 5.0;
+ Double actual = student.getTotalStudyTime();
+
+ Assert.assertEquals(expected,actual);
+
+
+ }
+
+ @Test
+ public void testImplementation(){
+ boolean instructorIsTeacher;
+ if(instructor instanceof Teacher){
+ instructorIsTeacher = true;
+ }
+ else{
+ instructorIsTeacher = false;
+ }
+ Assert.assertTrue(instructorIsTeacher);
+ }
+
+ @Test
+ public void testInheritance(){
+ boolean instructorIsTeacher;
+ if(instructor instanceof Teacher){
+ instructorIsTeacher = true;
+ }
+ else{
+ instructorIsTeacher = false;
+ }
+ Assert.assertTrue(instructorIsTeacher);
+ }
+
+ @Test
+ public void testTeach(){
+ instructor.teach(student, 3);
+
+ Double expectedTime = 3.0;
+ Double actualTime = student.getTotalStudyTime();
+
+ Assert.assertEquals(expectedTime, actualTime);
+ }
+
+ @Test
+ public void testLecture(){
+ Learner[] learners = {student};
+ instructor.lecture(learners,6);
+
+ Double expected = 6.0;
+ Double actual = student.getTotalStudyTime();
+
+ Assert.assertEquals(expected, actual);
+ }
+
+
+}
diff --git a/src/test/java/io/zipcoder/interfaces/TestInstructor.java b/src/test/java/io/zipcoder/interfaces/TestInstructor.java
new file mode 100644
index 00000000..6d093cbb
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/TestInstructor.java
@@ -0,0 +1,68 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestInstructor {
+ Instructor instructor;
+ Student student;
+ Student student2;
+
+ @Before
+ public void testContr(){
+ instructor = new Instructor(11, "Zan");
+ student = new Student(01, "Johnny");
+ student2 = new Student(02, "Elliot");
+ }
+
+ @Test
+ public void testImplementation(){
+ boolean instructorIsTeacher;
+ if(instructor instanceof Teacher){
+ instructorIsTeacher= true;
+ }
+ else{
+ instructorIsTeacher = false;
+ }
+ Assert.assertTrue(instructorIsTeacher);
+ }
+
+ @Test
+ public void testInheritance(){
+ boolean instructorIsTeacher;
+ if(instructor instanceof Teacher){
+ instructorIsTeacher = true;
+ }
+ else{
+ instructorIsTeacher = false;
+ }
+ Assert.assertTrue(instructorIsTeacher);
+ }
+
+ @Test
+ public void testTeach(){
+ instructor.teach(student, 3);
+
+ Double expectedTime = 3.0;
+ Double actualTime = student.getTotalStudyTime();
+
+ Assert.assertEquals(expectedTime, actualTime);
+ }
+
+ @Test
+ public void testLecture(){
+ Learner[] learners = {student, student2};
+ instructor.lecture(learners,6);
+
+ Double expected = 3.0;
+ Double actual = student.getTotalStudyTime();
+
+ Assert.assertEquals(expected, actual);
+ }
+
+
+
+
+
+}
diff --git a/src/test/java/io/zipcoder/interfaces/TestInstructors.java b/src/test/java/io/zipcoder/interfaces/TestInstructors.java
new file mode 100644
index 00000000..f288889b
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/TestInstructors.java
@@ -0,0 +1,21 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestInstructors {
+
+
+ @Test
+ public void test1(){
+ Person actualInstructor = null;
+ Long[] instructorArray = {0L, 1L};
+ Instructors actual = Instructors.getInstance();
+
+ for (int i = 0; i < instructorArray.length; i++) {
+ actualInstructor = actual.findById(instructorArray[i]);
+ }
+ Assert.assertTrue(actualInstructor != null);
+ }
+
+}
diff --git a/src/test/java/io/zipcoder/interfaces/TestPeople.java b/src/test/java/io/zipcoder/interfaces/TestPeople.java
new file mode 100644
index 00000000..1e8b8a80
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/TestPeople.java
@@ -0,0 +1,59 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestPeople {
+ People peopleObject;
+ Person person;
+ Person person2;
+ Person person3;
+
+
+ @Before
+ public void testContr(){
+ peopleObject = new People() {
+ public Person[] toArray() {
+ return new Person[0];
+ }
+ };
+ person = new Person(11, "Zan");
+ person2 = new Person(01, "Johnny");
+ person3 = new Person(02, "Elliot");
+ }
+
+ @Test
+ public void testAdd(){
+ peopleObject.add(person);
+
+ Integer expected = 1;
+ Integer actual = peopleObject.personList.size();
+
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void testRemove(){
+ peopleObject.add(person2);
+ peopleObject.add(person3);
+ peopleObject.remove(person2);
+
+ Integer expected = 1;
+ Integer actual = peopleObject.personList.size();
+
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void testFindById(){
+ peopleObject.add(person2);
+
+
+ Person expected = person2;
+ Person actualId = peopleObject.findById(1);
+
+ Assert.assertEquals(expected.getId(),actualId.getId());
+ }
+
+}
diff --git a/src/test/java/io/zipcoder/interfaces/TestPerson.java b/src/test/java/io/zipcoder/interfaces/TestPerson.java
index d64cd2f0..98ec091d 100644
--- a/src/test/java/io/zipcoder/interfaces/TestPerson.java
+++ b/src/test/java/io/zipcoder/interfaces/TestPerson.java
@@ -1,5 +1,31 @@
package io.zipcoder.interfaces;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
public class TestPerson {
+ Person person;
+
+ @Before
+ public void testConstructor() {
+ person = new Person(01, "Johnny");
+ }
+
+ @Test
+ public void testSetName(){
+ String expectedName = "Johnny";
+ long expectedId = 01;
+
+ String actualName = person.getName();
+ long actualId = person.getId();
+
+ Assert.assertEquals(expectedName, actualName);
+ Assert.assertEquals(expectedId, actualId);
+ }
+
+
+
+
}
diff --git a/src/test/java/io/zipcoder/interfaces/TestStudent.java b/src/test/java/io/zipcoder/interfaces/TestStudent.java
new file mode 100644
index 00000000..bedc7848
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/TestStudent.java
@@ -0,0 +1,55 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestStudent {
+ Student student;
+
+ @Before
+ public void testConst(){
+ student = new Student(01, "Johnny");
+ }
+
+ @Test
+ public void testImplementation(){
+ boolean studentIsLearner;
+ if(student instanceof Learner){
+ studentIsLearner = true;
+ }
+ else{
+ studentIsLearner = false;
+ }
+
+ Assert.assertTrue(studentIsLearner);
+ }
+
+ @Test
+ public void testInheritance(){
+ boolean studentIsPerson;
+ if(student instanceof Person){
+ studentIsPerson = true;
+ }
+ else{
+ studentIsPerson = false;
+ }
+
+ Assert.assertTrue(studentIsPerson);
+ }
+
+ @Test
+ public void testLearn(){
+ student.totalStudyTime = 1.0;
+ student.learn(1.5);
+
+ Double expectedTime = 2.5;
+ Double actualTime = student.getTotalStudyTime();
+
+ Assert.assertEquals(expectedTime, actualTime);
+ }
+
+
+
+
+}
diff --git a/src/test/java/io/zipcoder/interfaces/TestStudents.java b/src/test/java/io/zipcoder/interfaces/TestStudents.java
new file mode 100644
index 00000000..4bb3ae08
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/TestStudents.java
@@ -0,0 +1,24 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestStudents {
+
+ @Test
+ public void test1(){
+ Person actualStudent = null;
+ Long [] studentArray = {5L, 6L};
+ Students actual = Students.getInstance();
+
+ for (int i = 0; i < studentArray.length; i++) {
+ actualStudent = actual.findById(studentArray[i]);
+ }
+
+ Assert.assertTrue(actualStudent != null);
+ }
+
+
+
+
+}
diff --git a/src/test/java/io/zipcoder/interfaces/TestZipCodeWilmington.java b/src/test/java/io/zipcoder/interfaces/TestZipCodeWilmington.java
new file mode 100644
index 00000000..d4ea26e6
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/TestZipCodeWilmington.java
@@ -0,0 +1,23 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestZipCodeWilmington {
+
+ @Test
+ public void testHostLecture(){
+ ZipCodeWilmington zcw = ZipCodeWilmington.getInstance();
+ Students students = Students.getInstance();
+ Instructors instructors = Instructors.getInstance();
+
+ zcw.hostLecture(Educator.ZAN,3);
+
+ Assert.assertEquals(3, Educator.ZAN.getTimeWorked(),0);
+
+ }
+
+
+}
+
+