diff --git a/src/main/java/com/github/curriculeon/Classroom.java b/src/main/java/com/github/curriculeon/Classroom.java new file mode 100644 index 0000000..98bedb2 --- /dev/null +++ b/src/main/java/com/github/curriculeon/Classroom.java @@ -0,0 +1,51 @@ +package com.github.curriculeon; + +import java.util.*; + +/** + * Create a Classroom 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. +*/ + +/* Refactor the hostLecture method in the Classroom class by removing any intermediate casting trick(s).*/ + +public class Classroom { + private static final Students students = Students.getInstance(); + private static final Instructors instructors = Instructors.getInstance(); + + public void hostLecture(Teacher teacher, double numberOfHours) { + teacher.lecture((Learner[]) students.toArray(), numberOfHours); + } + + public void hostLecture(long id, double numberOfHours){ + Teacher teacher; + if (instructors.findById(id) instanceof Teacher) { + teacher = (Teacher) instructors.findById(id); + this.hostLecture(teacher, numberOfHours); + } + } + + public Map getStudyMap(){ + Iterator iterator = students.iterator(); + Map map = new HashMap<>(); + Student s ; + + while(iterator.hasNext()){ + //if (iterator.next() instanceof Student){ + //s = (Student)iterator.next(); + s = iterator.next(); + map.put(s, s.getTotalStudyTime()); + //} + } + return map; + } +} diff --git a/src/main/java/com/github/curriculeon/Instructor.java b/src/main/java/com/github/curriculeon/Instructor.java new file mode 100644 index 0000000..77daf4a --- /dev/null +++ b/src/main/java/com/github/curriculeon/Instructor.java @@ -0,0 +1,37 @@ +package com.github.curriculeon; + +/** + * Create Instructor Class + * Create an Instructor class such that: + * Instructor is a subclass of Person + * Instructor implements the Teacher interface + * Instructor should have a concrete implementation of the teach method + * which invokes the learn method on the specified Learner object. + * Instructor should have a concrete implementation of the lecture method + * which invokes the learn method on each of the elements in the specified array of Learner objects. + * numberOfHours should be evenly split amongst the learners. + * double numberOfHoursPerLearner = numberOfHours / learners.length; + */ + +/** + * Implemented By Monica Deshmukh + * 07/21/2020 + */ +public class Instructor extends Person implements Teacher { + + Instructor(long id, String name) { + super(id, name); + } + + @Override + public void teach(Learner learner, double numberOfHours) { + learner.learn(numberOfHours); + } + + @Override + public void lecture(Learner[] learners, double numberOfHours) { + for (Learner learner : learners) { + learner.learn(numberOfHours); + } + } +} diff --git a/src/main/java/com/github/curriculeon/Instructors.java b/src/main/java/com/github/curriculeon/Instructors.java new file mode 100644 index 0000000..50d3ee0 --- /dev/null +++ b/src/main/java/com/github/curriculeon/Instructors.java @@ -0,0 +1,35 @@ +package com.github.curriculeon; + +/** + * Use Part 7 as a reference. + * Create a Instructors singleton which represents the set of instructors. + * Create a TestInstructors class. + */ + +import java.util.List; + +/** + * Implemented by Monica Deshmukh + * 07/27/2020 + */ +public class Instructors extends People{ + private static final Instructors INSTANCE = new Instructors(); + + private Instructors() { + this.add(new Instructor(11,"instructor1")); + this.add(new Instructor(12,"instructor2")); + } + + public static Instructors getInstance() { + return INSTANCE; + } + + @Override + public Instructor[] toArray() { + //return INSTANCE.toArray(); + Instructor[] instructorArray = new Instructor[personList.size()];//should make a method in Person class to retrun personList.size() + List instructorList = personList; + instructorList.toArray(instructorArray); + return instructorArray; + } +} diff --git a/src/main/java/com/github/curriculeon/Learner.java b/src/main/java/com/github/curriculeon/Learner.java new file mode 100644 index 0000000..465b74a --- /dev/null +++ b/src/main/java/com/github/curriculeon/Learner.java @@ -0,0 +1,21 @@ +package com.github.curriculeon; + +/** + * Create a Learner interface. + * Learner should declare method signature: + * Method name: learn + * Method parameters: double numberOfHours + * Method return-type: void + * Learner should declare method signature: + * Method name: getTotalStudyTime + * Method return-type: Double + */ + +/** + * Implemeted By Monica Deshmukh + * 07/20/2020 + */ +public interface Learner { + public void learn (double numberOfHours); + public Double getTotalStudyTime(); +} diff --git a/src/main/java/com/github/curriculeon/People.java b/src/main/java/com/github/curriculeon/People.java new file mode 100644 index 0000000..512cbcb --- /dev/null +++ b/src/main/java/com/github/curriculeon/People.java @@ -0,0 +1,121 @@ +package com.github.curriculeon; + +import java.util.*; + +/** + * Implemented By Monica Deshmukh + * 07/22/2020 + */ + +/** + * Create a People class. +*/ + +/** + * Parameterize the People signature to enforce that it is a container for objects of type E + * such that E is a subclass of Person. + * Modify the class signature to declare this class abstract. + * An abstract class cannot be instantiated; Its concrete implementation is deferred to its subclass. + * 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 type E. + * An abstract method is a subclass's contractual agreement to the deferment + * of an implementation of a respective method. + */ + +/** + * Implemented by Monica Deshmukh 07/28/2020 + */ +public abstract class People implements Iterable{ + /* + * The class should instantiate a List field of Person objects named personList. + */ + List personList; + + public People() { + personList = new ArrayList(); + } + + /* + * The class should define a method named add which adds a Person to the personList. + */ + public void add(E personType) { + personList.add(personType); + } + /* + * The class should define a method named findById which makes use of + * a long id parameter to return a Person object with the respective id field. + */ + public E findById(long id) { + for (E personType: personList) { + //if (personList instanceof Person) + if (personType.getId() == id) + return personType; + } + return null; //person with id not found + } + + + /* findById using stream*/ + /** public Person findById(long id) { + return personList.stream().filter(person -> person.getId() == id).findFirst().get(); + }*/ + + /* + * The class should define a method named contains which makes use of + * a Person person parameter to return true if the personList contains the respective Person object. + */ + public Boolean contains(E personType) { + if (personList.contains(personType)) + return true; + return false; + } + /** + * The class should define a method named remove which makes use of + * * a Person person parameter to remove a respective Person object. + */ + public void remove(E personType) { + if (this.contains(personType)) + personList.remove(personType); + } + + /** + * * The class should define a method named remove which makes use of + * * a long id parameter to remove a Person object with the respective id field. + * + */ + public void remove(long id) { + remove(findById(id)); + } + /** + * * The class should define a named removeAll which clears our personList field. + */ + public void removeAll() { + personList.clear(); + } + /** + * * The class should define a method named count which returns the size of personList. + */ + public int count() { + return personList.size(); + } + + /** + * * The class should define a method named toArray + * which returns an array representation of the personList field. + * + */ + public abstract E[] toArray(); + + /** + * * The class should implement Iterable and define a method named iterator + * * which makes use of the personList field to generate a new a Iterator. + */ + @Override + public Iterator iterator() { + return personList.iterator(); + //return null; + } + +} diff --git a/src/main/java/com/github/curriculeon/Person.java b/src/main/java/com/github/curriculeon/Person.java index 3c8350b..057ccc1 100644 --- a/src/main/java/com/github/curriculeon/Person.java +++ b/src/main/java/com/github/curriculeon/Person.java @@ -1,5 +1,36 @@ package com.github.curriculeon; - +/** + * Create a Person class. + * The class should declare a final field named id of type long. + * The class should declare a field named name of type String. + * Person constructor should have a parameter of type long and String which sets the id and name field to the respective values. + * The class should define a getId() method which returns the Person object's id field. + * The class should define a getName() method which returns the Person object's name field. + * The class should define a setName() method which sets the Person object's name field. + */ +/** + * Implemented Person Class + * Monica Deshmukh + *07/20/2020 + */ public class Person { + final long id; + String name; + + Person(long id, String name){ + this.id = id; + this.name = name; + } + + public void setName(String name){ + this.name = name; + } + + public long getId(){ + return id; + } + public String getName(){ + return name; + } } diff --git a/src/main/java/com/github/curriculeon/Student.java b/src/main/java/com/github/curriculeon/Student.java new file mode 100644 index 0000000..823c2f6 --- /dev/null +++ b/src/main/java/com/github/curriculeon/Student.java @@ -0,0 +1,34 @@ +package com.github.curriculeon; + +/** + * Create Student Class + * Create a Student class such that: + * Student is a subclass of Person + * Student implements the Learner interface + * Student should have an instance variable totalStudyTime of type double + * Student should have a concrete implementation of the learn method which increments + * the totalStudyTime variable by the specified numberOfHours argument. + * Student should have a getTotalStudyTime() method which returns the totalStudyTime instance variable. + */ + +/** + * Implemented By Monica Deshmukh + * 07/20/2020 + */ +public class Student extends Person implements Learner{ + double totalStudyTime; + + public Student(long id, String name){ + super(id, name); + totalStudyTime = 0; + } + @Override + public void learn(double numberOfHours) { + totalStudyTime += numberOfHours; + } + + @Override + public Double getTotalStudyTime() { + return totalStudyTime; + } +} diff --git a/src/main/java/com/github/curriculeon/Students.java b/src/main/java/com/github/curriculeon/Students.java new file mode 100644 index 0000000..94616ba --- /dev/null +++ b/src/main/java/com/github/curriculeon/Students.java @@ -0,0 +1,54 @@ +package com.github.curriculeon; + +/** + * Note: The creation of this class will demonstrate an implementation of singleton design pattern. + * Create a Students class. + * The class should be an unextendable subclass of the People class. + * The class should statically instantiate a final field named INSTANCE of type Students. + * The class should define a private nullary constructor which populates the INSTANCE field + * with respective Student representations of your colleagues. + * Each student should have a relatively unique id field. + * The class should define a getInstance method which returns the INSTANCE field. + */ + +/** + * Implemented By Monica Deshmukh 07/24/2020 + */ +/** + * * Modify the Students class signature to ensure that it is a subclass of People of parameterized type Student. + */ + +import java.util.List; + +/** + * Implemented by Monica Deshmukh + * 07/28/2020 + */ +public class Students extends People{ + private static final Students INSTANCE = new Students(); + private Students() { + this.add(new Student(1, "student1")); + this.add(new Student(2, "student2")); + this.add(new Student(3, "student3")); + } + + public static Students getInstance() { + + return INSTANCE; + } + + @Override + public Student[] toArray() { + //return INSTANCE.toArray(); + //should return the list personList in people class as an array + //The personList (which is of type E) should be copied into StudentList of type Student. + //Then convert list toArray and return the array. + Student[] studentArray = new Student[personList.size()];//should make a method in Person class to retrun personList.size() + List studentList = personList; + studentList.toArray(studentArray); + return studentArray; + } + +} + + diff --git a/src/main/java/com/github/curriculeon/Teacher.java b/src/main/java/com/github/curriculeon/Teacher.java new file mode 100644 index 0000000..5fcf0a7 --- /dev/null +++ b/src/main/java/com/github/curriculeon/Teacher.java @@ -0,0 +1,31 @@ +package com.github.curriculeon; + +/** + * Create Teacher Interface + * + * Create a Teacher interface. + * Teacher should declare a teach method signature: + * + * Method name: teach + * Method parameters: + * Learner learner + * double numberOfHours + * Method return-type: void + * + * Teacher should declare a lecture method signature: + * + * Method name: lecture + * Method parameters: + * Learner[] learners + * double numberOfHours + * Method return-type: void + */ + +/** + * Implemented by Monica Deshmukh + * 07/21/2020 + */ +public interface Teacher { + void teach(Learner learner, double numberOfHours); + void lecture(Learner[] learners, double numberOfHours); +} diff --git a/src/test/java/com/github/curriculeon/TestClassroom.java b/src/test/java/com/github/curriculeon/TestClassroom.java new file mode 100644 index 0000000..0051f99 --- /dev/null +++ b/src/test/java/com/github/curriculeon/TestClassroom.java @@ -0,0 +1,40 @@ +package com.github.curriculeon; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * Create a Classroom 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. + */ +public class TestClassroom { + @Test + public void testHostLecture(){ + //given + Classroom classroom = new Classroom(); + double initialStudyHours, studyHoursAfterLecture; + double numberOfHoursStudied = 10; + + Map initialMap = classroom.getStudyMap(); + + //when + classroom.hostLecture(11, numberOfHoursStudied); + Map mapAfterHostLecture = classroom.getStudyMap(); + + //then + //for each student get initial study hours and compare with studyhours after lecture + for (Student student : initialMap.keySet()) + { + // search for value + initialStudyHours = initialMap.get(student); + studyHoursAfterLecture = mapAfterHostLecture.get(student); + double expectedStudeyHours = initialStudyHours+ numberOfHoursStudied; + Assert.assertEquals((long)expectedStudeyHours, (long)studyHoursAfterLecture); + } + } +} diff --git a/src/test/java/com/github/curriculeon/TestInstructor.java b/src/test/java/com/github/curriculeon/TestInstructor.java new file mode 100644 index 0000000..ec7ba05 --- /dev/null +++ b/src/test/java/com/github/curriculeon/TestInstructor.java @@ -0,0 +1,88 @@ +package com.github.curriculeon; + +/** + * Create a TestInstructor class. + * Create a testImplementation method that asserts that an Instructor is an instanceof a Teacher. + * Create a testInheritance method that asserts that a Instructor is an instanceof a Person. + * Create a testTeach method that ensures when an Instructor invokes the teach method, + * a respective student's totalStudyTime instance variable is incremented by the specified numberOfHours. + * Create a testLecture method that ensures when an Instructor invokes the lecture method, + * a respective array of students' totalStudyTime instance variables is incremented by numberOfHours/students.length. + */ + +import org.junit.Assert; +import org.junit.Test; + +/** + * Implemented by Monica Deshmukh + * 07/21/2020 + */ +public class TestInstructor { + @Test + public void testImplementation() { + //given + Instructor instructor = new Instructor(1, "Monica"); + + //when + Boolean outcome = instructor instanceof Teacher; + + // then + Assert.assertTrue(outcome); + } + + @Test + public void testInheritance() { + //given + Instructor instructor = new Instructor(1, "Monica"); + + //when + Boolean outcome = instructor instanceof Person; + + // then + Assert.assertTrue(outcome); + } + + @Test + public void testTeach() { + //given + Instructor instructor = new Instructor(1, "Monica"); + Student student = new Student(2, "student1"); + Double expectedStudyTime = 10D; + //when + instructor.teach(student, expectedStudyTime); + Double actualStudyTime = student.getTotalStudyTime(); + + //then + Assert.assertEquals(actualStudyTime, expectedStudyTime); + } + + @Test + public void testLecture() { + //given + Instructor instructor = new Instructor(11, "Monica"); + Student[] students = new Student[3]; + students[0] = new Student(1, "student1"); + students[1] = new Student(2, "student2"); + students[2] = new Student(3, "student3"); + Double initialStudyTime = 0D; + + for (Student s: students) { + initialStudyTime += s.getTotalStudyTime(); + } + + Double expectedStudyTime = 10D; + + //when + instructor.lecture(students, expectedStudyTime); + + Double actualTotalStudyTime = 0D; + for (Student s: students) { + actualTotalStudyTime += s.getTotalStudyTime(); + } + Double actualStudyTime = (initialStudyTime + actualTotalStudyTime)/students.length; + + //then + Assert.assertEquals(actualStudyTime, expectedStudyTime); + + } +} diff --git a/src/test/java/com/github/curriculeon/TestInstructors.java b/src/test/java/com/github/curriculeon/TestInstructors.java new file mode 100644 index 0000000..c913340 --- /dev/null +++ b/src/test/java/com/github/curriculeon/TestInstructors.java @@ -0,0 +1,22 @@ +package com.github.curriculeon; + +import org.junit.Assert; +import org.junit.Test; + +public class TestInstructors { + @Test + public void testInstructors(){ + //given + Instructors instructors = Instructors.getInstance(); + Instructor[] instructorsExpected = {new Instructor(11, "instructor1"), + new Instructor(12, "instructor2")}; + + //when + Person[] instructorsActual = instructors.toArray(); + + //then + for(int i = 0; i < 2; i++){ + Assert.assertEquals(instructorsExpected[i].getName(), instructorsActual[i].getName()); + } + } +} diff --git a/src/test/java/com/github/curriculeon/TestPeople.java b/src/test/java/com/github/curriculeon/TestPeople.java new file mode 100644 index 0000000..e0ef2ec --- /dev/null +++ b/src/test/java/com/github/curriculeon/TestPeople.java @@ -0,0 +1,90 @@ +package com.github.curriculeon; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Create a TestPeople class. + * Create a testAdd method which ensures that our personList in our People class + * populated with respective Person objects following invokation of the add method. + * Create a testRemove method which ensures that the personList in a People object + * is depopulated with a respective Person object following the invokation of the remove method. + * Create a testFindById method which ensures that a respective Person object with a respective id field + * is returned upon invokation of the findById method on a respective People object. + */ +public class TestPeople { + @Test + public void testAdd() { + //given + //People people = new People(); + People people = Students.getInstance(); + + //when + Person person1 = new Person(1, "person1"); + Person person2 = new Person(2, "person2"); + Person person3 = new Person(3, "person3"); + people.add(person1); + people.add(person2); + people.add(person3); + + //then + Assert.assertTrue(people.contains(person1)); + Assert.assertTrue(people.contains(person2)); + Assert.assertTrue(people.contains(person3)); + } + + @Test + public void testRemove() { + //given + //People people = new People(); + People people = Instructors.getInstance(); + + //when + //add two persons to the list. + //make sure they are added to the list. + //then remove a person from the list. + Person person1 = new Person(1, "person1"); + Person person2 = new Person(2, "person2"); + people.add(person1); + people.add(person2); + + Assert.assertTrue(people.contains(person1)); + Assert.assertTrue(people.contains(person2)); + + people.remove(person1); + + //then + //assert that the person is removed from the list + Assert.assertFalse(people.contains(person1)); + } + + @Test + public void testFindById() { + //given + //People people = new People(); + People people = Students.getInstance(); + //when + long id = 1; + /*Person person1 = new Person(1, "person1"); + Person person2 = new Person(2, "person2"); + Person person3 = new Person(3, "person3"); + people.add(person1); + people.add(person2); + people.add(person3);*/ + //then + Assert.assertTrue(people.contains(people.findById(id))); + + //when + id = 4; + //then + Assert.assertFalse(people.contains(people.findById(id))); + + //when + people = Instructors.getInstance(); + id = 11; + + //then + Assert.assertTrue(people.contains(people.findById(id))); + + } +} diff --git a/src/test/java/com/github/curriculeon/TestPerson.java b/src/test/java/com/github/curriculeon/TestPerson.java index 6c523fe..04c23c0 100644 --- a/src/test/java/com/github/curriculeon/TestPerson.java +++ b/src/test/java/com/github/curriculeon/TestPerson.java @@ -1,5 +1,56 @@ package com.github.curriculeon; +/** + * Create a TestPerson class. + * Create a testConstructor method which ensures that a Person object's id and name field + * are being set upon construction. + */ + +import org.junit.Assert; +import org.junit.Test; + +import java.time.LocalDate; +import java.time.Period; +import java.time.ZoneId; +import java.util.Date; + +/** + * Implemented by Monica Deshmukh + * 07/20/2020 + */ public class TestPerson { + private void testConstructor(long expectedId, String expectedName) { + //given: expectedId, expectedName + // When + Person person = new Person(expectedId, expectedName); + + + long actualId = person.getId(); + String actualName = person.getName(); + //then + Assert.assertEquals(expectedId, actualId); + Assert.assertEquals(expectedName, actualName); + } + @Test + public void test0() { + testConstructor(0, null); + } + @Test + public void test1() { + testConstructor(1, ""); + } + @Test + public void test2() { + testConstructor(-1, "Monica"); + } + + @Test + public void test3() { + testConstructor(Long.MAX_VALUE, "Deshmukh"); + } + + public void test4() { + testConstructor(Long.MIN_VALUE, "Deshmukh"); + } } diff --git a/src/test/java/com/github/curriculeon/TestSetName.java b/src/test/java/com/github/curriculeon/TestSetName.java new file mode 100644 index 0000000..c1a21e0 --- /dev/null +++ b/src/test/java/com/github/curriculeon/TestSetName.java @@ -0,0 +1,44 @@ +package com.github.curriculeon; + +/*** Create a testSetName method which ensures that a Person object's name variable is being set + * by invoking the .setName method. + */ + +import org.junit.Assert; +import org.junit.Test; + +/** Implemented by Monica Deshmukh + * 07/20/2020 + */ +public class TestSetName { + private void testSetName(String expectedName) { + //given + String name = expectedName + 1; //initialize name to a different value than expectedName + Person person = new Person(1, name); + + //when + person.setName(expectedName); //change the name using setName() method + + //then + String actualName = person.getName(); //assert if the name is changed + + Assert.assertEquals(expectedName, actualName); + } + + @Test + public void test0() { + testSetName("Monica"); + } + + @Test + public void test1() { + testSetName(""); + } + + @Test + public void test2() { + testSetName(null); + } +} + + diff --git a/src/test/java/com/github/curriculeon/TestStudent.java b/src/test/java/com/github/curriculeon/TestStudent.java new file mode 100644 index 0000000..d2c6f75 --- /dev/null +++ b/src/test/java/com/github/curriculeon/TestStudent.java @@ -0,0 +1,64 @@ +package com.github.curriculeon; + +/** + * Test Student + * Create a TestStudent class. + * Create a testImplementation method that asserts that a Student is an instanceof a Learner. + * Create a testInheritance method that asserts that a Student is an instanceof a Person. + * Create a testLearn method that ensures a Student's totalStudyTime instance variable + * is incremented by the specified numberOfHours by invoking the .learn method. + */ + +import org.junit.Assert; +import org.junit.Test; + +/** + * Implemented By Monica Deshmukh + * 07/20/2020 + */ +public class TestStudent { + @Test + public void testImplementation() { + //given a studentObject + long id = 5; + String name = "Monica"; + Student studentObject = new Student(id,name); + + //when a learner object could be created using a student object + Learner learnerObject = studentObject; + + //then asserts that a student is an instance of a learner object + Assert.assertEquals(studentObject, learnerObject); + } + + @Test + public void testInheritance() { + //given a student object + long id = 5; + String name = "Monica"; + Student studentObject = new Student(id,name); + + //when a personObject could be created using a studentObject + Person personObject = studentObject; + + //then asserts that a student is an instance of a person + Assert.assertEquals(studentObject, personObject); + } + + @Test + public void testLearn(){ + //given a student object + long id = 5; + String name = "Monica"; + Student student = new Student(id, name); + Double initialStudyHours = student.getTotalStudyTime(); + double expectedStudyHours = 10; + //when + student.learn(expectedStudyHours); + Double actualStudyTime = initialStudyHours + student.getTotalStudyTime(); + //then + Assert.assertEquals((Double)expectedStudyHours,actualStudyTime); + } + + +} diff --git a/src/test/java/com/github/curriculeon/TestStudents.java b/src/test/java/com/github/curriculeon/TestStudents.java new file mode 100644 index 0000000..eac231f --- /dev/null +++ b/src/test/java/com/github/curriculeon/TestStudents.java @@ -0,0 +1,34 @@ +package com.github.curriculeon; +import org.junit.Assert; +import org.junit.Test; +/** + * Create a TestStudents class. + * Create a test method which ensures that each of the students in your current cohort + * are in your Students singleton. + */ + +/** + * Implemented by Monica Deshmukh 07/24/2020 + */ +public class TestStudents { + @Test + public void testStudents() { + //given + Students students = Students.getInstance(); + /* Student[] studentCohort = { new Student(1, "student1"), + new Student(2, "student2"), + new Student(3, "student3")};*/ + //when + //Person[] studentArray = students.toArray(); + Student[] studentArray = students.toArray(); + + //then + for (int i = 1; i<= 3; i++){ + Assert.assertEquals(studentArray[i-1].getId(), i); + // + //Assert.assertEquals(studentArray[0].getId(), studentCohort[0].getId()); + //Assert.assertTrue(students.contains(studentCohort[i])); : physical Person objects are different, their properties are same + } + } + +}