Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please do it in java, no sort of any use of java libraries package junit_tests; import static org.junit.Assert.*; import org.junit.Test; /* * Requirement: Any classes

please do it in java, no sort of any use of java libraries

image text in transcribed

image text in transcribed

package junit_tests;

import static org.junit.Assert.*;

import org.junit.Test;

/* * Requirement: Any classes you create must reside in the `model` package and be imported properly. * For example, creating a new class `Foo` in the `model` package should result in: * import model.Foo; */ public class TestOnlineSchool { @Test public void test_01() { Instructor i = new Instructor("Jackie", 70130, "jackie@eecs.yorku.ca"); String name = i.getName(); int ext = i.getPhoneExtension(); String contact = i.getEmail(); String info = i.getInformation(); assertEquals("Jackie", name); assertEquals(70130, ext); assertEquals("jackie@eecs.yorku.ca", contact); assertEquals("Instructor Jackie has campus phone extension 70130 and contact email jackie@eecs.yorku.ca", info); i.setName("Jonathan"); i.setPhoneExtension(70139); i.setEmail("jonathan@yorku.ca"); assertEquals("Jonathan", i.getName()); assertEquals(70139, i.getPhoneExtension()); assertEquals("jonathan@yorku.ca", i.getEmail()); assertEquals("Instructor Jonathan has campus phone extension 70139 and contact email jonathan@yorku.ca", i.getInformation()); } /* * 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 r = new Registration("Software Design"); String t = r.getTitle(); int m = r.getMarks(); Instructor i = r.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(0, m); assertNull(i); assertTrue(gr.length == 2 && gr[0].equals("F") && gr[1].equals("Failing")); assertEquals("Software Design has not yet been assigned an instructor", info); Instructor jackie = new Instructor("Jackie", 70130, "jackie@eecs.yorku.ca"); r.setInstructor(jackie); assertEquals("Software Design", r.getTitle()); assertEquals(0, r.getMarks()); assertTrue(r.getInstructor() != null && r.getInstructor() == jackie /* reference aliasing */ /* Q. Can you visualize this chain of method calls? */ && r.getInstructor().getName().equals("Jackie") && r.getInstructor().getPhoneExtension() == 70130 && r.getInstructor().getEmail().equals("jackie@eecs.yorku.ca")); assertTrue(r.getGradeReport().length == 2); assertEquals(r.getGradeReport()[0], "F"); assertEquals(r.getGradeReport()[1], "Failing"); /* 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 0 (F ; Failing)", r.getInformation()); r.setMarks(61); assertEquals(61, r.getMarks()); assertTrue(r.getGradeReport().length == 2 && r.getGradeReport()[0].equals("C") && r.getGradeReport()[1].equals("Competent")); assertEquals("Software Design, taught by Jackie, is completed with raw marks 61 (C ; Competent)", r.getInformation()); Instructor jim = new Instructor("Jim Davies", 70139, "jim@yorku.ca"); r.setInstructor(jim); /* Q. Can you visualize why this assertion is true? */ assertTrue(r.getInstructor() != null && r.getInstructor() != jackie && r.getInstructor() == jim); assertEquals("Software Design, taught by Jim Davies, is completed with raw marks 61 (C ; Competent)", r.getInformation()); } /* * 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_02b() { /* Second argument of the constructor call is an anonymous object: * new Instructor("J. Gibbons", 76283, "jeremy@yorku.ca") */ Registration r = new Registration("Data Structures", new Instructor("J. Gibbons", 76283, "jeremy@yorku.ca")); r.setMarks(73); assertEquals("Data Structures", r.getTitle()); assertEquals(73, r.getMarks()); assertTrue(r.getInstructor().getName().equals("J. Gibbons") && r.getInstructor().getPhoneExtension() == 76283 && r.getInstructor().getEmail().equals("jeremy@yorku.ca") && r.getInstructor().getInformation().equals("Instructor J. Gibbons has campus phone extension 76283 and contact email jeremy@yorku.ca")); assertTrue(r.getGradeReport().length == 2 && r.getGradeReport()[0].equals("B") && r.getGradeReport()[1].equals("Good")); assertEquals("Data Structures, taught by J. Gibbons, is completed with raw marks 73 (B ; Good)", r.getInformation()); } /* * 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. */

pass these junit tests, thank you

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 A Excellent 70 - 79 B Good 60-69 Competent 50 - 59 49 Failing 9 8 C D F Passing 7 6 5 0 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 (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. public class TestOnlineSchool { * Requirement: Any classes you add to the model package must not contain any use of the Java library (e.g., ArrayList). * Tests included in this class serve as documentation on how instances of an online school operates. * Before attempting this lab, it is expected that you already completed the pre-study materials: 1. Week 7 Java Tutorials: https://www.youtube.com/playlist?list=PL5dxAmCmjv_7x3Qn5px_z5@qqgaBK95c1 2.1 Written Notes on Reference-Typed, Multi-Valued Attributes: https://www.eecs.yorku.ca/-jackie/teaching/lectures/2021/W/EECS1022otes/EECS1022_W21_Tracing_PointCollectorTester.pdf 2.2 The written notes in 2.1 will make it easier for you to follow Week 8's Java Tutorials: https://www.youtube.com/playlist?list=PL5dxAmCmjv_6JyoGf4zvQmg3pinzipWdb 4. Written Notes on Inferring Classes from JUnit Tests: https://www.eecs.yorku.cajackie/teaching/lectures/2021/W/EECS1022otes/EECS1022_W21_Inferring_Classes_from_JUnit.pdf * Item 2.2. will only be available on March 5. You may start attempting the lab after completing: Items 1, 2.1, and 4. * Be sure to also read the following sections from your Labs instructions PDF: - Section 2.3 The Online School Problem - Section 2.4 Hints and Requirements * Programming IDEs such as Eclipse are able to fix such compilation errors for you. * However, you are advised to follow the guidance as specified in the written notes above to fix these compilation errors manually, because: 1) it helps you better understand how the intended classes and methods work together; and 2) you may be tested in a written test or exam without the assistance of IDES. * * */ /* 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. */ 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 A Excellent 70 - 79 B Good 60-69 Competent 50 - 59 49 Failing 9 8 C D F Passing 7 6 5 0 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 (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. public class TestOnlineSchool { * Requirement: Any classes you add to the model package must not contain any use of the Java library (e.g., ArrayList). * Tests included in this class serve as documentation on how instances of an online school operates. * Before attempting this lab, it is expected that you already completed the pre-study materials: 1. Week 7 Java Tutorials: https://www.youtube.com/playlist?list=PL5dxAmCmjv_7x3Qn5px_z5@qqgaBK95c1 2.1 Written Notes on Reference-Typed, Multi-Valued Attributes: https://www.eecs.yorku.ca/-jackie/teaching/lectures/2021/W/EECS1022otes/EECS1022_W21_Tracing_PointCollectorTester.pdf 2.2 The written notes in 2.1 will make it easier for you to follow Week 8's Java Tutorials: https://www.youtube.com/playlist?list=PL5dxAmCmjv_6JyoGf4zvQmg3pinzipWdb 4. Written Notes on Inferring Classes from JUnit Tests: https://www.eecs.yorku.cajackie/teaching/lectures/2021/W/EECS1022otes/EECS1022_W21_Inferring_Classes_from_JUnit.pdf * Item 2.2. will only be available on March 5. You may start attempting the lab after completing: Items 1, 2.1, and 4. * Be sure to also read the following sections from your Labs instructions PDF: - Section 2.3 The Online School Problem - Section 2.4 Hints and Requirements * Programming IDEs such as Eclipse are able to fix such compilation errors for you. * However, you are advised to follow the guidance as specified in the written notes above to fix these compilation errors manually, because: 1) it helps you better understand how the intended classes and methods work together; and 2) you may be tested in a written test or exam without the assistance of IDES. * * */ /* 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. */

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

=+6. How does PR differ from advertising?

Answered: 1 week ago