diff --git a/.idea/$PRODUCT_WORKSPACE_FILE$ b/.idea/$PRODUCT_WORKSPACE_FILE$ new file mode 100644 index 00000000..79be3548 --- /dev/null +++ b/.idea/$PRODUCT_WORKSPACE_FILE$ @@ -0,0 +1,19 @@ + + + + + + + 11 + + + + + + + + \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..5c98b428 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# 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..2545dc75 --- /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/README.md b/README.md index 96882643..9256c5e1 100644 --- a/README.md +++ b/README.md @@ -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 new instance 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 new instance 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. @@ -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. - @@ -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` 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/pom.xml b/pom.xml index f0effe12..d2d2b237 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,19 @@ io.zipcoder interfaces-1 0.0.1-SNAPSHOT - jar + + + + org.apache.maven.plugins + maven-compiler-plugin + + 6 + 6 + + + + + jar interfaces-1 http://maven.apache.org 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..498e7a74 --- /dev/null +++ b/src/main/java/io/zipcoder/interfaces/Educator.java @@ -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; + } + +} 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..a735ec33 --- /dev/null +++ b/src/main/java/io/zipcoder/interfaces/Instructor.java @@ -0,0 +1,20 @@ +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[] learner, double numberOfHours) { + double numberOfHoursPerLearner = numberOfHours / learner.length; + for (Learner each : learner) { + each.learn(numberOfHoursPerLearner); + } + } +} \ No newline at end of file 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..b44c0da5 --- /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(); + + protected Instructors(){ + + for (Educator ed : Educator.values()) { + this.add(new Instructor(ed.getId(), ed.getName())); + } +// this.add(new Instructor(1, "Kris")); +// this.add(new Instructor(9, "Chris")); +// this.add(new Instructor(10, "Froilan")); +// this.add(new Instructor(11, "Dolio")); +// this.add(new Instructor(6, "Roberto")); + } + + public static Instructors getInstance() { + return INSTANCE; + } + + public Instructor[] toArray() { + Instructor[] result = new Instructor[INSTANCE.count()]; + int i = 0; + for (Instructor instructor: INSTANCE) { + result[i++] = instructor; + } + return result; + } +} 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..1f3079a1 --- /dev/null +++ b/src/main/java/io/zipcoder/interfaces/Learner.java @@ -0,0 +1,6 @@ +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..a3e7b3a4 --- /dev/null +++ b/src/main/java/io/zipcoder/interfaces/People.java @@ -0,0 +1,60 @@ +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 implements Iterable{ + private ArrayList eList; + + public People(ArrayList eList){ + this.eList = eList; + } + public People(){ + this.eList = new ArrayList(); + } + + public void add(E e) { + this.eList.add(e); + } + + public E findById(long id) { + for(E e : this.eList){ + if(e.getId() == id) { + return e; + } + } return null; + } + public boolean contains(E e) { + return this.eList.contains(e); + } + + public void remove(E e) { + this.eList.remove(e); + } + + public void remove(long id){ + E eToBeFound = this.findById(id); + if(eToBeFound != null) { + this.remove(eToBeFound); + } + } + + public void removeAll() { + this.eList.clear(); + } + + public int count() { + return this.eList.size(); + } + + abstract E[] toArray(); + + + public Iterator iterator() { + return this.eList.iterator(); + } +} diff --git a/src/main/java/io/zipcoder/interfaces/Person.java b/src/main/java/io/zipcoder/interfaces/Person.java index fc6a3ffe..a4193f68 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 { + 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; + } + 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..b392adc0 --- /dev/null +++ b/src/main/java/io/zipcoder/interfaces/Student.java @@ -0,0 +1,19 @@ +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; + } + + 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..30816ae8 --- /dev/null +++ b/src/main/java/io/zipcoder/interfaces/Students.java @@ -0,0 +1,33 @@ +package io.zipcoder.interfaces; + +public final class Students extends People { + + private static final Students INSTANCE = new Students(); + + protected Students(){ + + this.add(new Student(44, "Malcolm")); + this.add(new Student(17, "Charlotte")); + this.add(new Student(16 , "Chung")); + this.add(new Student(6, "Val")); + this.add(new Student(9, "Grace")); + this.add(new Student(3, "Manny")); + this.add(new Student(15, "Eddie")); + } + + public static Students getInstance() { + return INSTANCE; + } + public Student[] toArray() { + Student[] result = new Student[INSTANCE.count()]; + int i = 0; + for (Student student: INSTANCE) { + result[i++] = student; + } + return result; + } + + + + +} \ No newline at end of file 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..66bb58a3 --- /dev/null +++ b/src/main/java/io/zipcoder/interfaces/Teacher.java @@ -0,0 +1,6 @@ +package io.zipcoder.interfaces; + +public interface Teacher { + void teach(Learner learner, double numberOfHours); + 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..efb2a326 --- /dev/null +++ b/src/main/java/io/zipcoder/interfaces/ZipCodeWilmington.java @@ -0,0 +1,38 @@ +package io.zipcoder.interfaces; +import io.zipcoder.*; +import java.util.Arrays; +import java.util.HashMap; + +public final class ZipCodeWilmington { + Students students; + Instructors instructors; + private Educator educator; + private static final ZipCodeWilmington INSTANCE = new ZipCodeWilmington(); + + + public ZipCodeWilmington() { + this.instructors = Instructors.getInstance(); + this.students = Students.getInstance(); + } + + public void hostLecture(Teacher teacher, double numberOfHours) { + teacher.lecture(students.toArray(), numberOfHours); + } + + public void hostLecture(long id, double numberOfHours) { + Teacher teacher = instructors.findById(id); + hostLecture(teacher, numberOfHours); + } + + public HashMap getStudyMap() { + HashMap studyMap = new HashMap<>(); + for (Student student : students.toArray()) { + studyMap.put(student, student.getTotalStudyTime()); + } + return studyMap; + } + + public static ZipCodeWilmington getInstance(){ + return INSTANCE; + } +} 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..5c2e972f --- /dev/null +++ b/src/test/java/io/zipcoder/interfaces/EducatorTest.java @@ -0,0 +1,32 @@ +package io.zipcoder.interfaces; + +import static org.junit.Assert.*; + +import org.junit.Assert; +import org.junit.Test; + + public class EducatorTest { + + @Test + public void testImplementation() { + Assert.assertTrue(Educator.DOLIO instanceof Teacher); + } + + @Test + public void testTeach() { + Student student = new Student(23,"Miff"); + Educator.KRIS.teach(student, 12); + Assert.assertEquals(12, student.getTotalStudyTime(), .01); + Assert.assertEquals(12, Educator.KRIS.getTimeWorked(), .01); + } + + @Test + public void testLecture() { + Student student1 = new Student(23,"Miff"); + Student student2 = new Student(24,"Biff"); + Educator.FROILAN.lecture(new Student[]{student1,student2}, 12); + Assert.assertEquals(6, student1.getTotalStudyTime(), .01); + Assert.assertEquals(6, student2.getTotalStudyTime(), .01); + Assert.assertEquals(12, Educator.FROILAN.getTimeWorked(), .01); + } +} diff --git a/src/test/java/io/zipcoder/interfaces/InstructorTest.java b/src/test/java/io/zipcoder/interfaces/InstructorTest.java new file mode 100644 index 00000000..f9e4a14c --- /dev/null +++ b/src/test/java/io/zipcoder/interfaces/InstructorTest.java @@ -0,0 +1,53 @@ +package io.zipcoder.interfaces; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class InstructorTest { + Instructor instructor; + double totalStudyTime; + double numberOfHours; + + @Before + public void setUp() throws Exception { + instructor = new Instructor(100, "Charlotte"); + } + + @Test + public void testImplementation() { + Assert.assertTrue(instructor instanceof Teacher); + } + + @Test + public void testInheritance() { + Assert.assertTrue(instructor instanceof Person); + } + + @Test + public void teachTest() { + Student student = new Student(678978, "Val"); + double expected = 100.0; + instructor.teach(student, expected); + + Assert.assertEquals(expected, student.getTotalStudyTime(), 0.000001); + } + + @Test + public void lectureTest() { + Student[] students = new Student[4]; + + for (int i = 0; i < students.length; i++) { + students[i] = new Student(i, "Charlotte"); + } + instructor.lecture(students, 12); + + totalStudyTime += numberOfHours/students.length; + + Assert.assertEquals(3.0, students[1].getTotalStudyTime(), 0.0000001); + } + } + + diff --git a/src/test/java/io/zipcoder/interfaces/InstructorsTest.java b/src/test/java/io/zipcoder/interfaces/InstructorsTest.java new file mode 100644 index 00000000..f91ccdfb --- /dev/null +++ b/src/test/java/io/zipcoder/interfaces/InstructorsTest.java @@ -0,0 +1,25 @@ +package io.zipcoder.interfaces; + +import org.junit.Test; + +import static org.junit.Assert.*; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class InstructorsTest { + + + @Test + public void getInstance () { + Assert.assertEquals("Dolio", Instructors.getInstance().findById(75).getName()); + Assert.assertEquals("Kris", Instructors.getInstance().findById(74).getName()); + Assert.assertEquals("Christopher", Instructors.getInstance().findById(73).getName()); + Assert.assertEquals("Roberto", Instructors.getInstance().findById(72).getName()); + Assert.assertEquals("Froilan", Instructors.getInstance().findById(71).getName()); + + } +} \ No newline at end of file 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..04cfc946 --- /dev/null +++ b/src/test/java/io/zipcoder/interfaces/PeopleTest.java @@ -0,0 +1,52 @@ +package io.zipcoder.interfaces; + +import org.junit.Test; +import org.junit.Before; +import org.junit.Assert; + + +public class PeopleTest { + + private Students students; + private Student student1; + private Student student2; + private Student student3; + + @Before + public void setUp() throws Exception { + // people = new People(); + this.students = Students.getInstance(); + student1 = new Student(7, "Val"); + student2 = new Student(14, "Charlotte"); + student3 = new Student(19, "Chung"); + } + + @Test + public void addTest() { + Assert.assertEquals(7, students.count()); + students.add(student1); + Assert.assertEquals(8, students.count()); + } + + @Test + public void findByIdTest() { + students.add(student1); + students.add(student2); + students.add(student3); + + Assert.assertEquals(student3, students.findById(19)); + } + + @Test + public void removeTest() { + students.add(student1); + students.add(student2); + Assert.assertEquals(10, students.count()); + Assert.assertTrue(students.contains(student1)); + students.remove(student1); + Assert.assertEquals(9, students.count()); + Assert.assertFalse(students.contains(student1)); + } + + +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/interfaces/PersonTest.java b/src/test/java/io/zipcoder/interfaces/PersonTest.java new file mode 100644 index 00000000..57dff642 --- /dev/null +++ b/src/test/java/io/zipcoder/interfaces/PersonTest.java @@ -0,0 +1,14 @@ +package io.zipcoder.interfaces; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class PersonTest { + String name; + + @Test + public void setName() { + this.name = name; + } +} \ No newline at end of file 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..e78415ff --- /dev/null +++ b/src/test/java/io/zipcoder/interfaces/StudentTest.java @@ -0,0 +1,28 @@ +package io.zipcoder.interfaces; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class StudentTest { + Student student; + + @Before + public void setUp() throws Exception { + student = new Student(1, "Julia"); + } + + @Test + public void testImplementation() { + Assert.assertTrue(student instanceof Learner); + } + @Test + public void testInheritance() { + Assert.assertTrue(student instanceof Person); + } + @Test + public void testLearn() { + student.learn(14.0); + Assert.assertEquals(14.0, student.getTotalStudyTime(), 0); + } +} \ No newline at end of file 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..c00be463 --- /dev/null +++ b/src/test/java/io/zipcoder/interfaces/StudentsTest.java @@ -0,0 +1,22 @@ +package io.zipcoder.interfaces; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class StudentsTest { + + + @Test + public void getInstance () { + Assert.assertEquals("Malcolm", Students.getInstance().findById(44).getName()); + Assert.assertEquals("Charlotte", Students.getInstance().findById(17).getName()); + Assert.assertEquals("Chung", Students.getInstance().findById(16).getName()); + Assert.assertEquals("Val", Students.getInstance().findById(6).getName()); + Assert.assertEquals("Grace", Students.getInstance().findById(9).getName()); + Assert.assertEquals("Manny", Students.getInstance().findById(3).getName()); + Assert.assertEquals("Eddie", Students.getInstance().findById(15).getName()); + } + } diff --git a/src/test/java/io/zipcoder/interfaces/TestPerson.java b/src/test/java/io/zipcoder/interfaces/TestPerson.java deleted file mode 100644 index d64cd2f0..00000000 --- a/src/test/java/io/zipcoder/interfaces/TestPerson.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.zipcoder.interfaces; - -public class TestPerson { - -} 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..5f0fcf20 --- /dev/null +++ b/src/test/java/io/zipcoder/interfaces/ZipCodeWilmingtonTest.java @@ -0,0 +1,40 @@ +package io.zipcoder.interfaces; + +import org.junit.Test; +import org.junit.Assert; + +import static org.junit.Assert.*; +import java.util.HashMap; + +public class ZipCodeWilmingtonTest { + + + + @Test + public void testHostLecture() { + ZipCodeWilmington mySchool = ZipCodeWilmington.getInstance(); + + mySchool.hostLecture(6, 70); + + HashMap map = mySchool.getStudyMap(); + + for (Student student : map.keySet()) { + Assert.assertEquals(10, student.getTotalStudyTime(), .01); + } + } + + @Test + public void testHostLecturEducator() { + ZipCodeWilmington mySchool = new ZipCodeWilmington(); + + mySchool.hostLecture(Educator.ROBERTO, 70); + + HashMap map = mySchool.getStudyMap(); + + for (Student student : map.keySet()) { + Assert.assertEquals(10, student.getTotalStudyTime(), .01); + } + Assert.assertEquals(70, Educator.ROBERTO.getTimeWorked(), .01); + } +} +