diff --git a/.idea/$PRODUCT_WORKSPACE_FILE$ b/.idea/$PRODUCT_WORKSPACE_FILE$
new file mode 100644
index 00000000..3733e0d3
--- /dev/null
+++ b/.idea/$PRODUCT_WORKSPACE_FILE$
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
\ No newline at end of file
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..8f6ee9db
--- /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..273b71e7
--- /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/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..4e3316bc
--- /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/ConcretePeople.java b/src/main/java/io/zipcoder/interfaces/ConcretePeople.java
new file mode 100644
index 00000000..ff272a79
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/ConcretePeople.java
@@ -0,0 +1,10 @@
+package io.zipcoder.interfaces;
+
+public class ConcretePeople extends People{
+
+ public Person [] listToArray () {
+ Person[] myPeople = new Person[this.personList.size()];
+ myPeople = this.personList.toArray(myPeople);
+ return myPeople;
+ }
+}
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..7c909b96
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Educator.java
@@ -0,0 +1,30 @@
+package io.zipcoder.interfaces;
+
+public enum Educator implements Teacher {
+
+
+ KRIS(546L, "Kris"), CHRIS(547L, "Chris"), DOLIO (548L, "Dolio"), ROBERTO (549L, "Roberto"), FROILAN (550L, "Froilan");
+ Long id;
+ String name;
+
+
+ Educator(Long id, String name){
+ this.id = id;
+ this.name = name;
+ }
+
+ private Double timeTaught;
+
+ @Override
+ public void teach(Learner learner, Double numberOfHours) {
+ learner.learn(numberOfHours);
+ }
+
+ @Override
+ public void lecture(Double numberOfHours, Learner[] learners) {
+ Double numberOfHoursPerLearner = numberOfHours / learners.length;
+ for( Learner student : learners) {
+ student.learn(numberOfHoursPerLearner);
+ }
+ }
+}
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..204142f2
--- /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);
+ }
+
+ @Override
+ public void teach(Learner learner, Double numberOfHours) {
+ learner.learn(numberOfHours);
+ }
+
+ @Override
+ public void lecture ( Double numberOfHours, Learner[] learners) {
+ Double numberOfHoursPerLearner = numberOfHours / learners.length;
+ for( Learner student : learners) {
+ student.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..328b463a
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Instructors.java
@@ -0,0 +1,40 @@
+package io.zipcoder.interfaces;
+
+public class Instructors extends People {
+ private static Instructors INSTANCE;
+
+ private Instructors(){
+// Instructor Kris = new Instructor (546L, "Kris");
+// Instructor Chris = new Instructor (547L, "Chris");
+// Instructor Dolio = new Instructor (548L, "Dolio");
+// Instructor Roberto = new Instructor (549L, "Roberto");
+// Instructor Froilan = new Instructor (550L, "Froilan");
+// personList.add(Kris);
+// personList.add(Chris);
+// personList.add(Dolio);
+// personList.add(Roberto);
+// personList.add(Froilan);
+
+ }
+
+
+
+ public static Instructors getInstance(){
+ if(INSTANCE == null){
+ INSTANCE = new Instructors();
+ }
+ return INSTANCE;
+ }
+
+ static {
+ INSTANCE = new Instructors();
+ for (int i = 0; i < 5; i++) {
+ INSTANCE.addPerson(new Instructor(i + 2L, "INSTRUCTOR" + i));
+ }
+ }
+
+ @Override
+ public Instructor[] listToArray() {
+ return this.personList.toArray(new Instructor[0]);
+ }
+}
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..4d461c45
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Learner.java
@@ -0,0 +1,9 @@
+package io.zipcoder.interfaces;
+
+public interface Learner {
+
+ void learn (Double numberOfHours);
+
+ 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..d11bc2a3
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/People.java
@@ -0,0 +1,56 @@
+package io.zipcoder.interfaces;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public abstract class People implements Iterable{
+
+ List personList = new ArrayList<>();
+
+ public void addPerson (E person){
+ this.personList.add(person);
+ }
+
+ public E findById (Long id) {
+ E target = null;
+ for (E person : this.personList) {
+ if (person.getId().equals(id)) {
+ target = person;
+ break;
+ }
+ }
+ return target;
+ }
+
+ public Boolean containsPerson (E person) {
+ return this.personList.contains(person);
+ }
+
+ public Integer count () {
+ return personList.size();
+ }
+
+ public void removePerson (E person){
+ personList.remove(person);
+ }
+
+ public void removePersonById (Long id) {
+ E personToRemove = findById(id);
+ removePerson(personToRemove);
+ }
+
+
+ public void removeAll (){
+ personList.clear();
+ }
+
+ public abstract E [] listToArray () ;
+
+
+
+ @Override
+ public Iterator iterator() {
+ return this.personList.iterator();
+ }
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Person.java b/src/main/java/io/zipcoder/interfaces/Person.java
index fc6a3ffe..91a65a33 100644
--- a/src/main/java/io/zipcoder/interfaces/Person.java
+++ b/src/main/java/io/zipcoder/interfaces/Person.java
@@ -1,5 +1,23 @@
package io.zipcoder.interfaces;
public class Person {
+ private final Long id;
+ private String name;
+ public Long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Person (Long id, String name) {
+ this.id = id;
+ this. name = name;
+ }
+
+ 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..d3aa8ae2
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Student.java
@@ -0,0 +1,22 @@
+package io.zipcoder.interfaces;
+
+public class Student extends Person implements Learner {
+ private Double totalStudyTime;
+
+ public Student(Long id, String name) {
+ super(id, name);
+ this.totalStudyTime = 0D;
+ }
+
+ public void setTotalStudyTime(Double totalStudyTime) {
+ this.totalStudyTime = totalStudyTime;
+ }
+
+ public void learn(Double numberOfHours) {
+ this.totalStudyTime += numberOfHours;
+ }
+
+ public Double getTotalStudyTime() {
+ return this.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..2d270dd9
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Students.java
@@ -0,0 +1,33 @@
+package io.zipcoder.interfaces;
+
+public class Students extends People {
+ private static Students INSTANCE;
+
+ private Students(){};
+
+ public static Students getInstance(){
+ if(INSTANCE == null){
+ INSTANCE = new Students();
+ }
+ return INSTANCE;
+ }
+
+ static {
+ INSTANCE = new Students();
+ for (int i = 0; i < 35; i++) {
+ INSTANCE.addPerson(new Student(i+1L, "STUDENT"+i));
+ }
+ }
+
+
+ @Override
+ public Student[] listToArray() {
+ return this.personList.toArray(new Student[0]);
+ }
+}
+
+// //Eager Instantiation
+// //Nullary constructor with intialized Students
+// private Students() {
+// INSTANCE = new Students ()
+// }
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..29158d3f
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Teacher.java
@@ -0,0 +1,8 @@
+package io.zipcoder.interfaces;
+
+public interface Teacher {
+
+ void teach(Learner learner, Double numberOfHours);
+
+ void lecture (Double numberOfHours, Learner [] learners);
+}
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..422c6e03
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/ZipCodeWilmington.java
@@ -0,0 +1,39 @@
+package io.zipcoder.interfaces;
+
+import java.util.LinkedHashMap;
+
+public class ZipCodeWilmington {
+ //private static final ZipCodeWilmington INSTANCE = new ZipCodeWilmington();
+
+ //public ZipCodeWilmington getInstance() {
+// return INSTANCE;
+// }
+
+
+ private static final Students students = Students.getInstance();
+ private static final Instructors instructors = Instructors.getInstance();
+
+
+ public static void hostLecture(Teacher teacher, Double numberOfHours) {
+ teacher.lecture(numberOfHours, students.listToArray());
+ }
+
+ public static void hostLectureById(Long id, Double numberOfHours) {
+ hostLecture(instructors.findById(id), numberOfHours);
+
+ }
+
+ public static LinkedHashMap getStudyMap() {
+ LinkedHashMap myMap = new LinkedHashMap<>();
+ for (Student student : students) {
+ myMap.put(student, student.getTotalStudyTime());
+ }
+
+// for (int i = 0; i < students.listToArray().length; i++) {
+// myMap.put(students.listToArray()[i], students.listToArray()[i]
+//
+// }
+ return myMap;
+ }
+
+}
diff --git a/src/test/java/InstructorsTest.java b/src/test/java/InstructorsTest.java
new file mode 100644
index 00000000..bc161360
--- /dev/null
+++ b/src/test/java/InstructorsTest.java
@@ -0,0 +1,15 @@
+import io.zipcoder.interfaces.Instructor;
+import io.zipcoder.interfaces.Instructors;
+import io.zipcoder.interfaces.Students;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class InstructorsTest {
+
+ @Test
+ public void testSingleton () {
+ Instructors testSingleton = Instructors.getInstance();
+ Integer expected = 5;
+ Assert.assertEquals(expected, testSingleton.count());
+ }
+}
diff --git a/src/test/java/PeopleTest.java b/src/test/java/PeopleTest.java
new file mode 100644
index 00000000..447b0fdb
--- /dev/null
+++ b/src/test/java/PeopleTest.java
@@ -0,0 +1,2 @@
+public class PeopleTest {
+}
diff --git a/src/test/java/io/zipcoder/interfaces/EducatorTest.java b/src/test/java/io/zipcoder/interfaces/EducatorTest.java
new file mode 100644
index 00000000..1ae69baf
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/EducatorTest.java
@@ -0,0 +1,4 @@
+package io.zipcoder.interfaces;
+
+public class EducatorTest {
+}
diff --git a/src/test/java/io/zipcoder/interfaces/PeopleTest.java b/src/test/java/io/zipcoder/interfaces/PeopleTest.java
new file mode 100644
index 00000000..f750d116
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/PeopleTest.java
@@ -0,0 +1,85 @@
+package io.zipcoder.interfaces;
+
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+public class PeopleTest {
+
+private People people;
+private Person tp1, tp2, tp3, tp4;
+
+@Before
+public void setup () {
+ people = new ConcretePeople();
+ tp1 = new Person (8734L, "Pete");
+ tp2 = new Person (3847L, "Sammi");
+ tp3 = new Person (2234L, "Rachel");
+ tp4 = new Person (9987L, "Steven");
+ people.addPerson(tp1);
+ people.addPerson(tp2);
+ people.addPerson(tp3);
+
+}
+
+ @Test
+ public void addPerson() {
+ people.addPerson(tp4);
+ Assert.assertTrue(people.containsPerson(tp4));
+ }
+
+ @Test
+ public void addPerson2() {
+ Integer expected = 4;
+ people.addPerson(tp4);
+ Integer actual = people.count();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void findById() {
+ Person expected = tp2;
+ Person actual = people.findById(3847L);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void contains() {
+ Assert.assertTrue(people.containsPerson(tp3));
+ }
+
+ @Test
+ public void count() {
+ Integer expected = 3;
+ Integer actual = people.count();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void removePerson() {
+ people.removePerson(tp1);
+ Assert.assertFalse(people.containsPerson(tp1));
+ }
+
+ @Test
+ public void removePersonById() {
+ people.removePersonById(tp1.getId());
+ Assert.assertFalse(people.containsPerson(tp1));
+ }
+
+ @Test
+ public void removeAll() {
+ people.removeAll();
+ Integer expected = 0;
+ Assert.assertEquals(expected, people.count());
+ }
+
+ @Test
+ public void listToArray() {
+ Integer expected = 3;
+ Person [] personArray = people.listToArray();
+ Integer actual = personArray.length;
+ Assert.assertEquals(expected, actual);
+ }
+}
diff --git a/src/test/java/io/zipcoder/interfaces/StudentTest.java b/src/test/java/io/zipcoder/interfaces/StudentTest.java
new file mode 100644
index 00000000..4280f340
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/StudentTest.java
@@ -0,0 +1,44 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class StudentTest {
+ private Student testStudent;
+ private Double totalStudyTime;
+ private Double numberOfHours;
+
+ @Before
+ public void setUp() throws Exception {
+ testStudent = new Student(98764L, "Coolio");
+ }
+
+ @Test
+ public void instanceOfLearnerTest () { //test implementation that student implements Learner
+ Assert.assertTrue(testStudent instanceof Learner);
+ }
+
+ @Test
+ public void inheritanceTest () { //test inheritance that student extends Person
+ Assert.assertTrue(testStudent instanceof Person);
+ }
+
+ @Test
+ public void testLearn () {
+ Double expected = 25D;
+ testStudent.setTotalStudyTime(20D);
+ testStudent.learn(5.00);
+ Double actual = testStudent.getTotalStudyTime();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testLearn2 () {
+ Double expected = 15.5;
+ testStudent.learn(15.5);
+ Double actual = testStudent.getTotalStudyTime();
+ Assert.assertEquals(expected, actual);
+ }
+
+}
diff --git a/src/test/java/io/zipcoder/interfaces/StudentsTest.java b/src/test/java/io/zipcoder/interfaces/StudentsTest.java
new file mode 100644
index 00000000..98fc2971
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/StudentsTest.java
@@ -0,0 +1,15 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class StudentsTest {
+
+
+ @Test
+ public void testSingleton () {
+ Students testSingleton = Students.getInstance();
+ Integer expected = 35;
+ Assert.assertEquals(expected, testSingleton.count());
+ }
+}
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..25fc4e63
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/TestInstructor.java
@@ -0,0 +1,52 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestInstructor {
+ private Instructor myInstructor;
+ private Student myStudent, myStudent2;
+ private Student [] myStudentsArray;
+
+ @Before
+ public void setup () throws Exception{
+ myInstructor = new Instructor(44556L, "Mr. Trombello");
+ myStudent = new Student (9876L, "Hayden Parker");
+ myStudent2 = new Student (9996L, "Lula Parker");
+ myStudentsArray = new Student [2];
+ myStudentsArray[0] = myStudent;
+ myStudentsArray[1] = myStudent2;
+ }
+
+ @Test
+ public void instanceOfTeacherTest () {
+ Assert.assertTrue(myInstructor instanceof Teacher);
+ }
+
+ @Test
+ public void instanceOfPersonTest () {
+ Assert.assertTrue(myInstructor instanceof Person);
+ }
+
+ @Test
+ public void testTeach () {
+ Double expected = 8D;
+ myStudent.learn(8D);
+ Assert.assertEquals(expected, myStudent.getTotalStudyTime());
+ }
+
+ @Test
+ public void testLecture () {
+ Double expected = 4D;
+ myInstructor.lecture(8D, myStudentsArray);
+ Assert.assertEquals(expected, myStudent.getTotalStudyTime());
+ }
+
+ @Test
+ public void testLecture2 () {
+ Double expected = 4D;
+ myInstructor.lecture(8D, myStudentsArray);
+ Assert.assertEquals(expected, myStudent2.getTotalStudyTime());
+ }
+}
diff --git a/src/test/java/io/zipcoder/interfaces/TestPerson.java b/src/test/java/io/zipcoder/interfaces/TestPerson.java
index d64cd2f0..a69813fb 100644
--- a/src/test/java/io/zipcoder/interfaces/TestPerson.java
+++ b/src/test/java/io/zipcoder/interfaces/TestPerson.java
@@ -1,5 +1,40 @@
package io.zipcoder.interfaces;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
public class TestPerson {
+ private Person testPerson, testPerson1, testPerson2, testPerson3;
+
+ @Before
+ public void setUp() throws Exception {
+ testPerson = new Person (874312L, "David Smith");
+ testPerson1 = new Person (874311L, "Jeremy Smith");
+ testPerson2 = new Person (874316L, "Mary Smith");
+ testPerson3 = new Person (874318L, "Joel Smith");
+ }
+
+ @Test
+ public void constructorTest () {
+ Long expectedId = 874312L;
+ String expectedName = "David Smith";
+ Assert.assertEquals(expectedId, testPerson.getId());
+ Assert.assertEquals(expectedName, testPerson.getName());
+ }
+
+ @Test
+ public void getId() {
+ Long expectedId = 874311L;
+ Assert.assertEquals(expectedId, testPerson1.getId());
+ }
+
+ @Test
+ public void setName() {
+ String expectedName = "Waldo Smith";
+ testPerson.setName(expectedName);
+ Assert.assertEquals(expectedName, testPerson.getName());
+ }
}
+
diff --git a/src/test/java/io/zipcoder/interfaces/ZipCodeWilmingtonTest.java b/src/test/java/io/zipcoder/interfaces/ZipCodeWilmingtonTest.java
new file mode 100644
index 00000000..1f4bf398
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/ZipCodeWilmingtonTest.java
@@ -0,0 +1,81 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Map;
+
+public class ZipCodeWilmingtonTest {
+// Double numberOfHours;
+// Double totalStudyTime;
+// Students students = Students.getInstance();
+// //Instructors instructors = Instructors.getInstance();
+// Teacher teacher;
+// Student student;
+// ZipCodeWilmington zipCodeWilmington;
+
+ @Before
+ public void setUp() throws Exception {
+ Students students = Students.getInstance();
+ for (Student student : students){
+ student.setTotalStudyTime(0.0);
+ }
+
+
+ }
+
+ @Test
+ public void testHostLecture() {
+ Student student = Students.getInstance().findById(2L);
+ Instructor myInstructor = Instructors.getInstance().findById(2L);
+ ZipCodeWilmington.hostLecture(myInstructor, 35D);
+ Double expected = 1D;
+ Map studyMap = ZipCodeWilmington.getStudyMap();
+ Double actual = studyMap.get(student);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testSingleton() {
+ Student student = Students.getInstance().findById(2L);
+ Instructor myInstructor = Instructors.getInstance().findById(2L);
+ ZipCodeWilmington.hostLecture(myInstructor, 35D);
+ Map studyMap = ZipCodeWilmington.getStudyMap();
+ StringBuilder output = new StringBuilder();
+ for (Student someStudent : studyMap.keySet()) {
+ output.append(String.format("%s\t%s\n", someStudent.getName(), studyMap.get(someStudent)));
+ }
+ String actual = output.toString();
+ String expected = "STUDENT0\t1.0\n" + "STUDENT1\t1.0\n" + "STUDENT2\t1.0\n" + "STUDENT3\t1.0\n" +
+ "STUDENT4\t1.0\n" + "STUDENT5\t1.0\n" + "STUDENT6\t1.0\n" + "STUDENT7\t1.0\n" + "STUDENT8\t1.0\n" +
+ "STUDENT9\t1.0\n" + "STUDENT10\t1.0\n" + "STUDENT11\t1.0\n" + "STUDENT12\t1.0\n" + "STUDENT13\t1.0\n" +
+ "STUDENT14\t1.0\n" + "STUDENT15\t1.0\n" + "STUDENT16\t1.0\n" + "STUDENT17\t1.0\n" + "STUDENT18\t1.0\n" +
+ "STUDENT19\t1.0\n" + "STUDENT20\t1.0\n" + "STUDENT21\t1.0\n" + "STUDENT22\t1.0\n" + "STUDENT23\t1.0\n" +
+ "STUDENT24\t1.0\n" + "STUDENT25\t1.0\n" + "STUDENT26\t1.0\n" + "STUDENT27\t1.0\n" + "STUDENT28\t1.0\n" +
+ "STUDENT29\t1.0\n" + "STUDENT30\t1.0\n" + "STUDENT31\t1.0\n" + "STUDENT32\t1.0\n" + "STUDENT33\t1.0\n" + "STUDENT34\t1.0\n";
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void hostLectureByEnum () {
+ Student student = Students.getInstance().findById(2L);
+ Educator educator = Educator.ROBERTO;
+ ZipCodeWilmington.hostLecture(educator, 35D);
+ Double expected = 1D;
+ Map studyMap = ZipCodeWilmington.getStudyMap();
+ Double actual = studyMap.get(student);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void hostLectureByEnumId () {
+ Student student = Students.getInstance().findById(2L);
+ ZipCodeWilmington.hostLectureById(4L, 35D);
+ Double expected = 1D;
+ Map studyMap = ZipCodeWilmington.getStudyMap();
+ Double actual = studyMap.get(student);
+ Assert.assertEquals(expected, actual);
+ }
+
+}