Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Java to code answer Note:- a console application is not necessary - all jUnit tests given below mus pass to show that the

Please use Java to code answer

image text in transcribed

Note:- a console application is not necessary

- all jUnit tests given below mus pass to show that the code works as expected

- It is expected that the TestOnlineSchool JUnit class contains compilation errors. This is because that declarations and definitions of the required class(es) and method(s) it references are missing.

-Therefore, the tasks to complete are: 1. Inferring from the given JUnit tests, add the missing class(es) and method(s) and pass all jUnit tests

portions of the jUnit test class "TestOnlineSchool" are copied below due to lack of space to upload everything (please make sure at least the following tests all pass):

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

(pasted in order)

B D F 9 8 7 6 5 0 2.3 The Online School Problem 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 (e.g., 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 numerical 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 Excellent 70 - 79 Good 60 - 69 Competent 50 - 59 Passing 0 - 49 Failing - 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 mimber of registrations allowed for a participant is 5: attempting to add registrations beyond this limit will have no impact (i... the list of registrations remains the same). Furthermore, there is no need to check if there are duplicated registrations added (e.g., two registrations with the same course name). - Retrieve its list of registrations as an array (i.e., Registration[]), whose length is less than or equal to the maximum allowable number i.e., 5). - Clear its list of registrations (e.g., 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 (i.e., the list of participants remains the same). Furthermore, there is no need to check if there are duplicated participants added (e.g., 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 test03a() { Instructor alan = new Instructor ("A. Wassyng", 70130, "jackie@eecs.yorku.ca"); Instructor mark = new Instructor("M. Lawford", 70139, "jonathan@yorku.ca"); Participant suyeon = new Participant("S. Y. Lee"); /* * 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[] suyeonRegistrations = suyeon.getRegistrations(); String report = suyeon.getGPAReport(); /* empty list of registrations to begin with */ assertTrue (suyeonRegistrations.length == 0); /* GPA undefined over an empty list of registrations */ assertEquals("No GPA available yet for S. Y. Lee", report); /* non-registered courses have default marks -1 */ assertTrue (suyeon.marksOf("Intro. to OOP") -1); assertTrue (suyeon.marksof("Heavy Metal Music") -1); assertTrue (suyeon.marksOf("Psychology I") == -1); Registration r1 = new Registration("Intro. to OOP", alan); /* add two registrations for suyeon * Hints: - Are the two addRegistration calls denote the same method? - Or an overloaded method (i.e., methods with the same name but distinct input parameter types)? */ suyeon.addRegistration (ri); suyeon.addRegistration ("Heavy Metal Music"); assertTrue (suyeon.getRegistrations().length == 2 && suyeon.getRegistrations ( [0] == r1 && suyeon.getRegistrations() [1].getTitle().equals("Heavy Metal Music") && suyeon.getRegistrations()[1].getInstructor() == null); assertTrue (suyeon.getRegistrations() [O].getMarks) assertTrue (suyeon.getRegistrations()[1].getMarks) 0); assertTrue (suyeon.marksof("Intro. to OOP") 0); /* now a registered course */ assertTrue (suyeon.marksOf("Heavy Metal Music") ); /* now a registered course */ assertTrue (suyeon.marksOf("Psychology I") == -1); /* still a non-registered course */ suyeon.getRegistrations() [1].setInstructor (mark); assertTrue (suyeon.getRegistrations()[1].getInstructor() mark); == == == * /* * Notice the format of GPA report: 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 {O (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 ( [0].getMarks) 61); /* Grade: C; GP: 6 */ assertTrue (suyeon.getRegistrations()[1].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 (8)}: 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", alan)); /* Q. Can you understand the two occurrences of anonymous objects below? */ yuna.addRegistration(new Registration "Psychology I", new Instructor("Tom", 70141, "tom@yorku.ca")); yuna.updateMarks ("Heavy Metal Music", 85); yuna.updateMarks("Intro. to OOP", 58); yuna.updateMarks ("Psychology I", 66); assertTrue(yuna.getRegistrations() [@].getMarks() == 85); /* Grade: A; GP: 8 */ assertTrue (yuna.getRegistrations() [1].getMarks() == 58); /* Grade: D; GP: 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 I") == 66); assertEquals("Y. Lee's GPA of {8 (A), 5 (D), 6 (C)}: 6.3", yuna.getGPAReport()); /* Suyeon and Yuna are classmates of two courses, * but the registration objects are distinct. */ assertEquals(suyeon.getRegistrations ( [0].getTitle(), yuna.getRegistrations() [1].getTitle(); assertTrue (suyeon.getRegistrations() [0] != yuna.getRegistrations ([1]); assertEquals(suyeon.getRegistrations() [1].getTitle(), yuna.getRegistrations() [@].getTitle()); assertTrue (suyeon.getRegistrations() [1] != yuna.getRegistrations()[0]); /* At the end of the semester, clear registrations of students. */ suyeon.clearRegistrations(); yuna.clearRegistrations(); assertTrue (suyeon.getRegistrations().length == 0 && yuna.getRegistrations().length == ); assertTrue (suyeon.getGPAReport().equals("No GPA available yet for S. Y. Lee") && yuna.getGPAReport().equals("No GPA available yet for Y. Lee")); String[] courses = {"Intro. to OOP", "Heavy Metal Music", "Psychology I", "Software Design"}; /* 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 ( [0].getMarks) 61); /* Grade: C; GP: 6 */ assertTrue (suyeon.getRegistrations()[1].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 (8)}: 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", alan)); /* Q. Can you understand the two occurrences of anonymous objects below? */ yuna.addRegistration(new Registration "Psychology I", new Instructor("Tom", 70141, "tom@yorku.ca")); yuna.updateMarks ("Heavy Metal Music", 85); yuna.updateMarks("Intro. to OOP", 58); yuna.updateMarks ("Psychology I", 66); assertTrue(yuna.getRegistrations() [@].getMarks() == 85); /* Grade: A; GP: 8 */ assertTrue (yuna.getRegistrations() [1].getMarks() == 58); /* Grade: D; GP: 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 I") == 66); assertEquals("Y. Lee's GPA of {8 (A), 5 (D), 6 (C)}: 6.3", yuna.getGPAReport()); /* Suyeon and Yuna are classmates of two courses, * but the registration objects are distinct. */ assertEquals(suyeon.getRegistrations ( [0].getTitle(), yuna.getRegistrations() [1].getTitle(); assertTrue (suyeon.getRegistrations() [0] != yuna.getRegistrations ([1]); assertEquals(suyeon.getRegistrations() [1].getTitle(), yuna.getRegistrations() [@].getTitle()); assertTrue (suyeon.getRegistrations() [1] != yuna.getRegistrations()[0]); /* At the end of the semester, clear registrations of students. */ suyeon.clearRegistrations(); yuna.clearRegistrations(); assertTrue (suyeon.getRegistrations().length == 0 && yuna.getRegistrations().length == ); assertTrue (suyeon.getGPAReport().equals("No GPA available yet for S. Y. Lee") && yuna.getGPAReport().equals("No GPA available yet for Y. Lee")); String[] courses = {"Intro. to OOP", "Heavy Metal Music", "Psychology I", "Software Design"}; /* Q. Without the loop below, * how many lines of assertions need to be written explicitly? */ for(int i = 0; i

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago