Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do it in eclipse and no library classes 9 8 7 6 You are required to develop an object-oriented program solving a (simplified) online school

Do it in eclipse and no library classes
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
9 8 7 6 You are required to develop an object-oriented program solving a (simplified) online school problem, where there is a list of participants registered in courses taught by qualified instructors: . Each instructor is characterized by their name, campus phone extension (c.8.70310), and contact email . Each registration is characterized by its subject title, numerical marks, and instructor (who may not be assigned when the course is first created). Given a registration object: - A grade report may be returned as an array of length 2, e.g-, ("B". "Good"), where the first element stores the letter grade and the second element stores its qualitative description. Consider the following table summarizing how each mamerical marks (assumed to range between 0 and 100) maps to its grade, description (whose spellings should be exact), and grade point: Range of Raw Marks Letter Grade Qualitative Description Grade Point 90 - 100 A+ Exceptional 80 - 89 A Excellent 70 - 79 B Good 60 - 69 Competent 50 - 59 Passing 5 0 - 49 Failing 0 - A string information object may be returned. There are two cases to consider, depending on whether or not the course instructor has been assigned. In the case where the instructor is present, the returned string should contain the course title, instructor name, the marks, and its corresponding grade and description (see the above mapping table). Each participant object is characterized by the name of student and the list of added registrations. Given a participant object, we may: - Add a new registration, either by an input registration object, or by the name of course (from which a registration object may be created accordingly). The maximum number of registrations allowed for a participant is 5: attempting to add registrations beyond this limit will have no impact (i.e., the list of registrations remains the same). Furthermore, there is no need to check if there are duplicated registrations added (c.8., two registrations with the same course name). -- Retrieve its list of registrations as an array (i... Registration[]), whose length is less than or equal to the maximum allowable number (i.e., 5). - Clear its list of registrations (eg, allowing further registrations to be added). Retrieve the marks of a course with the given name. If the name of a non-registered course is given, then return -1 as its marks Update the marks of a course with the given name. If the name of a non-registered course is given, then nothing should be changed. - Obtain a report of the GPA (grade point average) over the list of added registrations. Each online school object is characterized by its list of participants. Given an online school object, we may: - Add a new participant by an input participant object. The maximum number of participants allowed for a school is 100: attempting to add participants beyond this limit will have no impact (ie, the list of participants remains the same). Furthermore, there is no need to check if there are duplicated participants added (6.8 two participants with the same name) - Retrieve the list of participants of a course, given its name, as an array. If the input name denotes a non-existing course, then an empty array is returned. Other intended functionalities of above kinds of objects can be inferred from the given JUnit test class TestOnlineSchool @Test public void test_01() { Instructor i = new Instructor("Jackie", 70130, "Jackiefeecs.yorku.ca"); String name - 1.getName(); Int ext - i.getPhoneExtension(); String contact - i.getEmail(); String info .i.get Information(); assertEquals("Jackie", name); assertEquals(70130, ext); assertEquals"Jackieeeecs.yorku.ca", contact); assertEquals("Instructor Jackie has campus phone extension 78138 and contact email jackiebeecs.yorku.ca", info); 1.setName("Jonathan"); 1.setPhoneExtension(70139); 1.setEnail("Jonathan@yorku.ca") assertEquals("Jonathan", 1.getiane()); assertEquals(70139, 1. getPhoneExtension()); assertEquals("Jonathan@yorku.ca", 1.getEasil()); assertEquals("instructor Jonathan has campus phone extension 70139 and contact email jonathan@yorku.ca, 1. get Information()); Recommended exercises: Visualizing and tracing (on both debugger and paper) on how objects are created and manipulated in each test would be extremely valuable for reinforcing your understanding. */ @Test public void test_02a() { Registration renew Registration Software Design); String t = r.getTitle(); int - r.getMarks(); Instructor i ar.getInstructor(); /* Size of returned array should be 2: . - ist element denotes the letter grade. - 2nd etenent denotes its qualitative description (see the mapping table in the instructions PDF). e/ String() gr = r.getGradeReport(); String info r.getInformation(); Returned information only displays the marks, grade, and description when there is an instructor. / assertEquals("Software Design", t): assertEquals(e, s); assert public void test_e2a() { Registration renew Registration("Software Design"); String ter.getTitle(); int nr.getMarks() Instructor i ar.getInstructor(); /* Size of returned array should be 2: * - 1st element denotes the letter grade. - 2nd element denotes its qualitative description (see the mapping table in the instructions PDF). */ String() gr = r.getGradeReport(); Returned information only displays the marks, grade, and description when there is an instructor. */ String info = r.getInformation(); assertEquals("Software Design", t); assertEquals(e, m); assertNull(i); assertTrue(gr. Length = 2 w grlo).equals("F") & grt1).equals("Failing"); assertEquals("Software Design has not yet been assigned an instructor", Into); Instructor jackie = new Instructor("Jackie", 70130, "jackieeecs.yorku.ca") r.setInstructor(jackie); assertEquals("Software Design", r.getTitle()); assertEquals(@, r.getMarks(); assertTrue(r.getInstructor() != null 6 r.getInstructor() = jackie /* reference aliasing */ # Q. Can you visualize this chain of method calls? */ r.getInstructor().getName().equals("Jackie") sr.getInstructor).getEnosti).equals"Jacklegeecs.yorku.ca")); assertTrue(r.getGradeReport().length2) assertEquals(r.getGradeReport() (), "F"); assertEqualsir.getGradeReport til, "Failing"); 7 when the instructor is assigned for the course, its information displays: - Title of course Name of instructor - Numerical marks, the corresponding letter grade, and its qualitative description. Note. Here we only test one case of mapping from marks to its grade and description. You should test other cases (see the mapping table in the instructions PDF). assertEquals("Software Design, taught by Jackie, is completed with raw marks (F : Falling)", r.getInformation()); r.setMarks (61); assertEquals(61, r.getMarks(); assertTruer.getGradeReport().length - 2 && r.getGradeReport (1o).equals("C") "")) assertEquals("Software Design, taught by Jackie, is completed with raw marks 61 (c; competent)", r.getInformation()); Instructor in new Instructor("Jim Davies", 70139, "imayorku.ca"); r.setInstructor(im); /* Q. Can you visualize why this assertion is true? / assertTruer.getInstructor != null 66 r.getInstructor != Jackie 66 r.getInstructor() - Jim): assertEqualsi software Design, taught by Jin Davies, is completed with raw marks 61 (C: Competent)", n. get information()); } @Test public void test_82b() { /Second argument of the constructor call is an anonymous object: new Instructor("3. SARA", 76283, "econycka") Registration r. new Registration("Data Structures", new Instructor("3. Gibbons", 76283. "Jeremyeyorku.ca")); r.setMarks (73) I assertEquals("Data Structuresker.getTitle()); assertEquals(73, r.getMarks()); assertTruer.getInstructor.getName().equals("3. Gibbons") r.getInstructor).getPhoneExtension() - 76283 r.getInstructor.getEmail().equals("ferent yorku.ca") ur.getInstructor get information().equals("Instructor's. Glhbons has campus phone extension 76203 and contact email Jeremyeyorku.ca")); essertTruotr.getGradelloportil Length 2 4 r.getGradeReport 19.equals("") 46 r.getGradelleportti).equals("Good")) assertEquals("Data Structures, taught by J. Gibbons, is completed with raw sarks 73 ( ; Good)", r.getInformation()); } eTest public void test() { Instructor alan new Instructor. Massyng" 70130, Jackiefeecs.yorku.ca") Instructor mark new Instructor'". Lawford", 70139, "jonathan yorku.ca") Participant suyeon now Participant("s. Y. Loe") Length of the returned array from getRegistrations corresponds to the number of registrations added by the participant so far. . See the instructions PDF regarding the max number of registrations that can be added. Registration suyeonRegistration suyeon.gethegistrations(); string reportsuyeon.getGPReport(); de espty list of registrations to begin with / assert TruetsuyeonRegistrations. Length - els / GPA undefined over an empty list of registrations / assertEquals("No GPA available yet for S. Y. Lee", report) e non-registered courses have default wurks 1 :/ assert True suyeon.marksoftIntro. to OOP)-1) assert Truesvyeon. Barksopteavy Metal Music") -1) assert Truetsuyeon. BarkloffPaychology 1") - 133 Registration in Registration "Intro. to op, stands add two registrations for swego Hintsi - Are the two addregistration calls denote the same method - Or an overloaded method (1... Methods with the same name but distinct input parameter types17 suyeon.addregistration ra); suyeon.addregistration Heavy Metal Music"); assert True (suyeon.getRegistrations().length - 2 & suyton.getRegistrations() 16 suyeon.getRegistrations (ta).getTitle().equals("Heavy Metal Music") assert Truelsuyeon.getRegistrations (10.getMarka) - suyeon.getRegistrations.getInstructor() - LUI assert Truelsuyeon.getRegistrations () 11).getMarks()); assert True (suyeon.marksof("Intro to OOP) = 0) / NOW a registered course / assert Truelsuyeon.marksOf("Heavy Metal Music) - 0); /e now a registered courses/ assertTrue (suyeon.larksof("Psychology 1") = -1); / still a non-registered course / suyeon.gethegistrations() 01).setInstructor(sark); assert Truetsuyeon.gethegistrations()(1).getInstructor() - Nark) Notice the format of GPA reporti - GPA value is displayed with 1 digit after the decimal point. - The comma-separated list of "Gradepoint (LetterGrade) is surrounded by curly braces. - There is a space after each comma and after the colon. assertEquals("s. Y. Lee's GPA of 6 (P), (F): 0.0", suyeon.getGPReport()); suyeon.pdaterarks ("Intro to Op. 61) suyeon.spdateraris heavy Metal Musie", 79); 14 non-ex tine course de nothing suyeon.s Cellarks("Psychology 1", 89) assert Tresen.getRegistrations.etarks() = 61): / Grade C GPI 66/ assert Truelswyeon.getRegistrations in otharks - 79) Grade i ojci./ assert Trve suyeon.mark of Heavy Metal Music")79) assert True suyeon. Barksoff"Psychology 1") = -1) / GPA of GPs divided by number of courses / assertEqualsis. Y. Lee's GPA of 6 (c), 7 (B)1 6.5", suyeon.getGPReport) Participant yuns - new Participant("Y. Lee) yuna addregistration Registration Heavy Metal Music", arka yun.addregistrationner Registration("Intre. te Oop", alan))i 10. Can you understand the two occurrences of anonymous objects below! / yun.addiegistration Registration *Psychology T. ne Instructor Tow"70141, "ton yerku.ca") yun.update iarksHeavy Metal Music",) yuna.pdatetarks ("Intro to Op.59) yuna.pdateraksi"Puychology 1", 6) assertrutyun.gethegistrations.getharks 05) / Grade A GPI & assertTruelyna. Registrations.getMarks sai Gradet Di GP: assert True. Registrations().gelarks() 60) Gradei ci GPL assert Truyun. Arkson Heavy Metal Musi85) assertTrve yuna, Berksoi Entro. to 1 - 58) assert Trwelyne.arkson Psychology 1") 66) assertEquality. Lee's GPA of (TA), (D), (c): 0.3", yuna getPesert 1 SMS and are classmates of the courses, but the registration objecte are distinct. 1. Syysen and Yuna are classmates of two courses, * but the registration objects are distinct. assertEquals(suyeon.getRegistrations (200).getTitle(), yuna.getRegistrations() (1).getTitle()) assertTrue(suyeon.getRegistrations() 18.!" yuno:getRegistrations() [1]); assertEquals(suyeon.getRegistrations (011).getTitle(), yuna.getRegistrations() to).getTitle(); assert True(suyeon.getRegistrations() [ij i. yuna.getRegistrations() tel); 1 At the end of the senester, clear registrations of students. suyeon.clearRegistrations(); yuna.clearRegistrations(); assert True (suyeon.getRegistrations().length = 4 yuna.getRegistrations(). Length - 0); assert Truelsuyeon.getGPAReport.equals("No GPA available yet for s. Y, Lee") U yuna getGPAReport().equals("No GPA available yet for Y, Lee")) String courses ("Intro to OOP", Heavy Metal Music","Psychology 1 Software Design") /* Q. Without the loop below, how many lines of assertions need to be written explicitly? */ for(int i = 1 courses, length1). assert True (suyeon.marksot(courses (1))) assertTrue(yuna,marksor (courses (11)-1); Next senester, students may choose to re-take some courses. */ suyeon, addRegistration ("Heavy Metal Music") suyeon updateMarks("Heavy Metal Music", 99); assertTrve suyeon.getRegistrations().length - 1); assertEquals("S. Y. Lee's GPA of 1+9.0", suyeon. getGPAReport()); assertEquals("Heavy Metal Music has not yet been assigned an instructor", suyeon, getRegistrations() [0).getInformation()); @Test public void test03b() { Participant heeyeon = new Participant("H. Y. Kang"); Registration r1 = new Registration ("EECS2001"); Registration r2 = new Registration("EECS2011"); Registration r3 = new Registration ("EECS2021"); Registration r4 = new Registration ("EECS2031"); Registration r5 = new Registration("EECS1096"); Registration[] list = {ri, r2, r3, r4, r5}; /* Q. Without the loop below, * how many lines of assertions need to be written explicitly? for(int i = 0; i do nothing / suyeon.updateMarks ("Psychology I", 89) assertTrue (suyeon.getRegistrations doi.getMarks() == 61); /* Grade: C: GP: 6 W assertTrue (suyeon.getRegistrationsiiti).getMarks() - 79); /* Grade: B; GP: 7 */ assert True (suyeon.marksOf("Intro. to OOP") - 61); assertTrue (suyeon.marksOf("Heavy Metal Music") - 79); assert True (suyeon.marksof("Psychology I") = -1); 1. GPA - sum of GPs divided by number of courses / assertEquals("S. Y. Lee's GPA of 6 (c), 7 (8)): 6.5", suyeon.getGPAReport()); Java assertEquals("S. Y. Lee's GPA of {(F), O (F)}: 0.0", suyeon.getGPAReport()); suyeon.updateMarks("Intro. to OOP", 61); suyeon.updateMarks("Heavy Metal Music", 79); /* non-existing course -> do nothing */ suyeon.updateMarks("Psychology I", 89); assertTrue (suyeon.getRegistrations() toi.getMarks() = 61); /* Grade: C; GP: 6 */ assertTrue (suyeon.getRegistrations() ii).getMarks() = 79); /* Grade: B; GP: 7 */ assertTrue(suyeon.marksof("Intro. to OOP) = 61); assertTrue (suyeon.marksof("Heavy Metal Music") - 79); assertTrue (suyeon.marksOf("Psychology I") == -1); /* GPA = sum of GPs divided by number of courses */ assertEquals("s. Y. Lee's GPA of 6 (c), 7 (B)): 6.5", suyeon.getGPAReport()); Participant yuna = new Participant("Y. Lee"); yuna.addRegistration(new Registration("Heavy Metal Music", mark)); yuna.addRegistration(new Registration("Intro. to OOP", a lan)); 1* Q. Can you understand the two occurrences of anonymous objects below? / yuna.addRegistration(new Registration "Psychology I", new Instructor("Tom", 70141, "tomayorku.ca"))); yuna.updateMarks ("Heavy Metal Music", 85); yuna.updateMarks "Intro. to OOP", 58), yuna.updateMarks ("Psychology I", 66); assertTrue(yuna.getRegistrations (10).getMarks() -- 85); /* Grade: A; GP: 8 */ assertTrue (yuna.getRegistrations (2/1).getMarks) - 58); /* Grade: DGP: 5 / assertTrue (yuna.getRegistrations() (2).getMarks() -- 66); /* Grade: C; GP: 6 */ assertTrue (yuna.marksof("Heavy Metal Music") - 85); assertTrue (yuna.marksof("Intro. to OOP") - 58); assertTrue (yuna.marksOf("Psychology 1") - 66); assertEquals("y. Lee's GPA of (a (h), (n), 7(c)): 6.3", yuna.getGPAReport()); /* SUYS. and Yuna are classmates of two courses, but the registration objects are distinct. / assertEquals(suyeon.getRegistrations (200).getTitle(), yuna.getRegistrations() (1).getTitle()); assertEquals(suyeon.getRegistrations (it).getTitle(), yuna.getRegistrations() to).getTitle()); assert True (suyeon.getRegistrations() [1] i- yuna.getRegistrations() [0]) /* At the end of the semester, clear registrations of students. */ suyeon.clearRegistrations(); yuna.clearRegistrations(); assertTrue (suyeon.getRegistrations().length - 6 yuna.getRegistrations().length = 0); assertTrue (suyeon.getGPAReport().equals("No GPA available yet for s. Y. Lee") 46 yuna.getGPAReport().equals("No GPA available yet for Y. Lee"). String() courses - ("Intro. to OOP", "Heavy Metal Music", "Psychology I", "Software Design"); /* 0. Without the loop below, * how many lines of assertions need to be written explicitly? for(int i = 0; i mark &6 list2(1) -- tom): assertTrue (list3.length - 1 && list3(0) -- tom); I /* non-existing course +/ assertTrue (school.getParticipants("How to Make Fish and Chips"). length = 0); 9 8 7 6 You are required to develop an object-oriented program solving a (simplified) online school problem, where there is a list of participants registered in courses taught by qualified instructors: . Each instructor is characterized by their name, campus phone extension (c.8.70310), and contact email . Each registration is characterized by its subject title, numerical marks, and instructor (who may not be assigned when the course is first created). Given a registration object: - A grade report may be returned as an array of length 2, e.g-, ("B". "Good"), where the first element stores the letter grade and the second element stores its qualitative description. Consider the following table summarizing how each mamerical marks (assumed to range between 0 and 100) maps to its grade, description (whose spellings should be exact), and grade point: Range of Raw Marks Letter Grade Qualitative Description Grade Point 90 - 100 A+ Exceptional 80 - 89 A Excellent 70 - 79 B Good 60 - 69 Competent 50 - 59 Passing 5 0 - 49 Failing 0 - A string information object may be returned. There are two cases to consider, depending on whether or not the course instructor has been assigned. In the case where the instructor is present, the returned string should contain the course title, instructor name, the marks, and its corresponding grade and description (see the above mapping table). Each participant object is characterized by the name of student and the list of added registrations. Given a participant object, we may: - Add a new registration, either by an input registration object, or by the name of course (from which a registration object may be created accordingly). The maximum number of registrations allowed for a participant is 5: attempting to add registrations beyond this limit will have no impact (i.e., the list of registrations remains the same). Furthermore, there is no need to check if there are duplicated registrations added (c.8., two registrations with the same course name). -- Retrieve its list of registrations as an array (i... Registration[]), whose length is less than or equal to the maximum allowable number (i.e., 5). - Clear its list of registrations (eg, allowing further registrations to be added). Retrieve the marks of a course with the given name. If the name of a non-registered course is given, then return -1 as its marks Update the marks of a course with the given name. If the name of a non-registered course is given, then nothing should be changed. - Obtain a report of the GPA (grade point average) over the list of added registrations. Each online school object is characterized by its list of participants. Given an online school object, we may: - Add a new participant by an input participant object. The maximum number of participants allowed for a school is 100: attempting to add participants beyond this limit will have no impact (ie, the list of participants remains the same). Furthermore, there is no need to check if there are duplicated participants added (6.8 two participants with the same name) - Retrieve the list of participants of a course, given its name, as an array. If the input name denotes a non-existing course, then an empty array is returned. Other intended functionalities of above kinds of objects can be inferred from the given JUnit test class TestOnlineSchool @Test public void test_01() { Instructor i = new Instructor("Jackie", 70130, "Jackiefeecs.yorku.ca"); String name - 1.getName(); Int ext - i.getPhoneExtension(); String contact - i.getEmail(); String info .i.get Information(); assertEquals("Jackie", name); assertEquals(70130, ext); assertEquals"Jackieeeecs.yorku.ca", contact); assertEquals("Instructor Jackie has campus phone extension 78138 and contact email jackiebeecs.yorku.ca", info); 1.setName("Jonathan"); 1.setPhoneExtension(70139); 1.setEnail("Jonathan@yorku.ca") assertEquals("Jonathan", 1.getiane()); assertEquals(70139, 1. getPhoneExtension()); assertEquals("Jonathan@yorku.ca", 1.getEasil()); assertEquals("instructor Jonathan has campus phone extension 70139 and contact email jonathan@yorku.ca, 1. get Information()); Recommended exercises: Visualizing and tracing (on both debugger and paper) on how objects are created and manipulated in each test would be extremely valuable for reinforcing your understanding. */ @Test public void test_02a() { Registration renew Registration Software Design); String t = r.getTitle(); int - r.getMarks(); Instructor i ar.getInstructor(); /* Size of returned array should be 2: . - ist element denotes the letter grade. - 2nd etenent denotes its qualitative description (see the mapping table in the instructions PDF). e/ String() gr = r.getGradeReport(); String info r.getInformation(); Returned information only displays the marks, grade, and description when there is an instructor. / assertEquals("Software Design", t): assertEquals(e, s); assert public void test_e2a() { Registration renew Registration("Software Design"); String ter.getTitle(); int nr.getMarks() Instructor i ar.getInstructor(); /* Size of returned array should be 2: * - 1st element denotes the letter grade. - 2nd element denotes its qualitative description (see the mapping table in the instructions PDF). */ String() gr = r.getGradeReport(); Returned information only displays the marks, grade, and description when there is an instructor. */ String info = r.getInformation(); assertEquals("Software Design", t); assertEquals(e, m); assertNull(i); assertTrue(gr. Length = 2 w grlo).equals("F") & grt1).equals("Failing"); assertEquals("Software Design has not yet been assigned an instructor", Into); Instructor jackie = new Instructor("Jackie", 70130, "jackieeecs.yorku.ca") r.setInstructor(jackie); assertEquals("Software Design", r.getTitle()); assertEquals(@, r.getMarks(); assertTrue(r.getInstructor() != null 6 r.getInstructor() = jackie /* reference aliasing */ # Q. Can you visualize this chain of method calls? */ r.getInstructor().getName().equals("Jackie") sr.getInstructor).getEnosti).equals"Jacklegeecs.yorku.ca")); assertTrue(r.getGradeReport().length2) assertEquals(r.getGradeReport() (), "F"); assertEqualsir.getGradeReport til, "Failing"); 7 when the instructor is assigned for the course, its information displays: - Title of course Name of instructor - Numerical marks, the corresponding letter grade, and its qualitative description. Note. Here we only test one case of mapping from marks to its grade and description. You should test other cases (see the mapping table in the instructions PDF). assertEquals("Software Design, taught by Jackie, is completed with raw marks (F : Falling)", r.getInformation()); r.setMarks (61); assertEquals(61, r.getMarks(); assertTruer.getGradeReport().length - 2 && r.getGradeReport (1o).equals("C") "")) assertEquals("Software Design, taught by Jackie, is completed with raw marks 61 (c; competent)", r.getInformation()); Instructor in new Instructor("Jim Davies", 70139, "imayorku.ca"); r.setInstructor(im); /* Q. Can you visualize why this assertion is true? / assertTruer.getInstructor != null 66 r.getInstructor != Jackie 66 r.getInstructor() - Jim): assertEqualsi software Design, taught by Jin Davies, is completed with raw marks 61 (C: Competent)", n. get information()); } @Test public void test_82b() { /Second argument of the constructor call is an anonymous object: new Instructor("3. SARA", 76283, "econycka") Registration r. new Registration("Data Structures", new Instructor("3. Gibbons", 76283. "Jeremyeyorku.ca")); r.setMarks (73) I assertEquals("Data Structuresker.getTitle()); assertEquals(73, r.getMarks()); assertTruer.getInstructor.getName().equals("3. Gibbons") r.getInstructor).getPhoneExtension() - 76283 r.getInstructor.getEmail().equals("ferent yorku.ca") ur.getInstructor get information().equals("Instructor's. Glhbons has campus phone extension 76203 and contact email Jeremyeyorku.ca")); essertTruotr.getGradelloportil Length 2 4 r.getGradeReport 19.equals("") 46 r.getGradelleportti).equals("Good")) assertEquals("Data Structures, taught by J. Gibbons, is completed with raw sarks 73 ( ; Good)", r.getInformation()); } eTest public void test() { Instructor alan new Instructor. Massyng" 70130, Jackiefeecs.yorku.ca") Instructor mark new Instructor'". Lawford", 70139, "jonathan yorku.ca") Participant suyeon now Participant("s. Y. Loe") Length of the returned array from getRegistrations corresponds to the number of registrations added by the participant so far. . See the instructions PDF regarding the max number of registrations that can be added. Registration suyeonRegistration suyeon.gethegistrations(); string reportsuyeon.getGPReport(); de espty list of registrations to begin with / assert TruetsuyeonRegistrations. Length - els / GPA undefined over an empty list of registrations / assertEquals("No GPA available yet for S. Y. Lee", report) e non-registered courses have default wurks 1 :/ assert True suyeon.marksoftIntro. to OOP)-1) assert Truesvyeon. Barksopteavy Metal Music") -1) assert Truetsuyeon. BarkloffPaychology 1") - 133 Registration in Registration "Intro. to op, stands add two registrations for swego Hintsi - Are the two addregistration calls denote the same method - Or an overloaded method (1... Methods with the same name but distinct input parameter types17 suyeon.addregistration ra); suyeon.addregistration Heavy Metal Music"); assert True (suyeon.getRegistrations().length - 2 & suyton.getRegistrations() 16 suyeon.getRegistrations (ta).getTitle().equals("Heavy Metal Music") assert Truelsuyeon.getRegistrations (10.getMarka) - suyeon.getRegistrations.getInstructor() - LUI assert Truelsuyeon.getRegistrations () 11).getMarks()); assert True (suyeon.marksof("Intro to OOP) = 0) / NOW a registered course / assert Truelsuyeon.marksOf("Heavy Metal Music) - 0); /e now a registered courses/ assertTrue (suyeon.larksof("Psychology 1") = -1); / still a non-registered course / suyeon.gethegistrations() 01).setInstructor(sark); assert Truetsuyeon.gethegistrations()(1).getInstructor() - Nark) Notice the format of GPA reporti - GPA value is displayed with 1 digit after the decimal point. - The comma-separated list of "Gradepoint (LetterGrade) is surrounded by curly braces. - There is a space after each comma and after the colon. assertEquals("s. Y. Lee's GPA of 6 (P), (F): 0.0", suyeon.getGPReport()); suyeon.pdaterarks ("Intro to Op. 61) suyeon.spdateraris heavy Metal Musie", 79); 14 non-ex tine course de nothing suyeon.s Cellarks("Psychology 1", 89) assert Tresen.getRegistrations.etarks() = 61): / Grade C GPI 66/ assert Truelswyeon.getRegistrations in otharks - 79) Grade i ojci./ assert Trve suyeon.mark of Heavy Metal Music")79) assert True suyeon. Barksoff"Psychology 1") = -1) / GPA of GPs divided by number of courses / assertEqualsis. Y. Lee's GPA of 6 (c), 7 (B)1 6.5", suyeon.getGPReport) Participant yuns - new Participant("Y. Lee) yuna addregistration Registration Heavy Metal Music", arka yun.addregistrationner Registration("Intre. te Oop", alan))i 10. Can you understand the two occurrences of anonymous objects below! / yun.addiegistration Registration *Psychology T. ne Instructor Tow"70141, "ton yerku.ca") yun.update iarksHeavy Metal Music",) yuna.pdatetarks ("Intro to Op.59) yuna.pdateraksi"Puychology 1", 6) assertrutyun.gethegistrations.getharks 05) / Grade A GPI & assertTruelyna. Registrations.getMarks sai Gradet Di GP: assert True. Registrations().gelarks() 60) Gradei ci GPL assert Truyun. Arkson Heavy Metal Musi85) assertTrve yuna, Berksoi Entro. to 1 - 58) assert Trwelyne.arkson Psychology 1") 66) assertEquality. Lee's GPA of (TA), (D), (c): 0.3", yuna getPesert 1 SMS and are classmates of the courses, but the registration objecte are distinct. 1. Syysen and Yuna are classmates of two courses, * but the registration objects are distinct. assertEquals(suyeon.getRegistrations (200).getTitle(), yuna.getRegistrations() (1).getTitle()) assertTrue(suyeon.getRegistrations() 18.!" yuno:getRegistrations() [1]); assertEquals(suyeon.getRegistrations (011).getTitle(), yuna.getRegistrations() to).getTitle(); assert True(suyeon.getRegistrations() [ij i. yuna.getRegistrations() tel); 1 At the end of the senester, clear registrations of students. suyeon.clearRegistrations(); yuna.clearRegistrations(); assert True (suyeon.getRegistrations().length = 4 yuna.getRegistrations(). Length - 0); assert Truelsuyeon.getGPAReport.equals("No GPA available yet for s. Y, Lee") U yuna getGPAReport().equals("No GPA available yet for Y, Lee")) String courses ("Intro to OOP", Heavy Metal Music","Psychology 1 Software Design") /* Q. Without the loop below, how many lines of assertions need to be written explicitly? */ for(int i = 1 courses, length1). assert True (suyeon.marksot(courses (1))) assertTrue(yuna,marksor (courses (11)-1); Next senester, students may choose to re-take some courses. */ suyeon, addRegistration ("Heavy Metal Music") suyeon updateMarks("Heavy Metal Music", 99); assertTrve suyeon.getRegistrations().length - 1); assertEquals("S. Y. Lee's GPA of 1+9.0", suyeon. getGPAReport()); assertEquals("Heavy Metal Music has not yet been assigned an instructor", suyeon, getRegistrations() [0).getInformation()); @Test public void test03b() { Participant heeyeon = new Participant("H. Y. Kang"); Registration r1 = new Registration ("EECS2001"); Registration r2 = new Registration("EECS2011"); Registration r3 = new Registration ("EECS2021"); Registration r4 = new Registration ("EECS2031"); Registration r5 = new Registration("EECS1096"); Registration[] list = {ri, r2, r3, r4, r5}; /* Q. Without the loop below, * how many lines of assertions need to be written explicitly? for(int i = 0; i do nothing / suyeon.updateMarks ("Psychology I", 89) assertTrue (suyeon.getRegistrations doi.getMarks() == 61); /* Grade: C: GP: 6 W assertTrue (suyeon.getRegistrationsiiti).getMarks() - 79); /* Grade: B; GP: 7 */ assert True (suyeon.marksOf("Intro. to OOP") - 61); assertTrue (suyeon.marksOf("Heavy Metal Music") - 79); assert True (suyeon.marksof("Psychology I") = -1); 1. GPA - sum of GPs divided by number of courses / assertEquals("S. Y. Lee's GPA of 6 (c), 7 (8)): 6.5", suyeon.getGPAReport()); Java assertEquals("S. Y. Lee's GPA of {(F), O (F)}: 0.0", suyeon.getGPAReport()); suyeon.updateMarks("Intro. to OOP", 61); suyeon.updateMarks("Heavy Metal Music", 79); /* non-existing course -> do nothing */ suyeon.updateMarks("Psychology I", 89); assertTrue (suyeon.getRegistrations() toi.getMarks() = 61); /* Grade: C; GP: 6 */ assertTrue (suyeon.getRegistrations() ii).getMarks() = 79); /* Grade: B; GP: 7 */ assertTrue(suyeon.marksof("Intro. to OOP) = 61); assertTrue (suyeon.marksof("Heavy Metal Music") - 79); assertTrue (suyeon.marksOf("Psychology I") == -1); /* GPA = sum of GPs divided by number of courses */ assertEquals("s. Y. Lee's GPA of 6 (c), 7 (B)): 6.5", suyeon.getGPAReport()); Participant yuna = new Participant("Y. Lee"); yuna.addRegistration(new Registration("Heavy Metal Music", mark)); yuna.addRegistration(new Registration("Intro. to OOP", a lan)); 1* Q. Can you understand the two occurrences of anonymous objects below? / yuna.addRegistration(new Registration "Psychology I", new Instructor("Tom", 70141, "tomayorku.ca"))); yuna.updateMarks ("Heavy Metal Music", 85); yuna.updateMarks "Intro. to OOP", 58), yuna.updateMarks ("Psychology I", 66); assertTrue(yuna.getRegistrations (10).getMarks() -- 85); /* Grade: A; GP: 8 */ assertTrue (yuna.getRegistrations (2/1).getMarks) - 58); /* Grade: DGP: 5 / assertTrue (yuna.getRegistrations() (2).getMarks() -- 66); /* Grade: C; GP: 6 */ assertTrue (yuna.marksof("Heavy Metal Music") - 85); assertTrue (yuna.marksof("Intro. to OOP") - 58); assertTrue (yuna.marksOf("Psychology 1") - 66); assertEquals("y. Lee's GPA of (a (h), (n), 7(c)): 6.3", yuna.getGPAReport()); /* SUYS. and Yuna are classmates of two courses, but the registration objects are distinct. / assertEquals(suyeon.getRegistrations (200).getTitle(), yuna.getRegistrations() (1).getTitle()); assertEquals(suyeon.getRegistrations (it).getTitle(), yuna.getRegistrations() to).getTitle()); assert True (suyeon.getRegistrations() [1] i- yuna.getRegistrations() [0]) /* At the end of the semester, clear registrations of students. */ suyeon.clearRegistrations(); yuna.clearRegistrations(); assertTrue (suyeon.getRegistrations().length - 6 yuna.getRegistrations().length = 0); assertTrue (suyeon.getGPAReport().equals("No GPA available yet for s. Y. Lee") 46 yuna.getGPAReport().equals("No GPA available yet for Y. Lee"). String() courses - ("Intro. to OOP", "Heavy Metal Music", "Psychology I", "Software Design"); /* 0. Without the loop below, * how many lines of assertions need to be written explicitly? for(int i = 0; i mark &6 list2(1) -- tom): assertTrue (list3.length - 1 && list3(0) -- tom); I /* non

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions