Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Create a UML and Java Application utilizing the below requirements Requirements 1. Design a Person abstract class as follows a. Three private instance Strings i.

Create a UML and Java Application utilizing the below requirements

Requirements 1. Design a Person abstract class as follows a. Three private instance Strings i. personId ii. lastName iii. firstName b. Public getters and setters for each instance variable. c. A public toString method with no parameters, returning a String which lists the values of the three instance variables as ordered above and separated by a tab character (\t). d. Implements the Comparable interface. i. http://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html ii. https://docs.oracle.com/javase/tutorial/collections/interfaces/order.html iii. As a requirement of implementing Comparable this class must override the int compareTo(Person) method. This should order the Person objects according to the order of their lastNames, and if the lastNames are the same then use the order of their firstNames. 2. Design an Instructor class as follows a. Extends the Person abstract class. b. Two additional private instance Strings i. title ii. department c. Public getters and setters for the new instance variables. d. Overrides the toString method from Person, returning the result of Persons toString method (super.toString()) with the two additional instance variables appended to the end, also separated by tab characters (\t). 3. Design a Student class as follows a. Extends the Person abstract class. b. Two additional private instance variables i. major, a String ii. gpa, a double c. Public getters and setters for the new instance variables. d. Overrides the toString method from Person, returning the result of its Persons toString method (super.toString()) with the two additional instance variables appended to the end, also separated by tab characters (\t). 4. Design a Course class as follows a. Five private instance variables i. courseId, a String 1. We call this a CRN like 48765 and it is unique for each class section. ii. courseName, a String (i.e. Introduction to Programming with Java) iii. courseCode, a String (i.e. CITP 190) iv. instructor, an Instructor object representing the teacher of the course b. A final List object named roster which represents the list of students enrolled in the course c. Public getters and setters for each instance variable except for roster. d. A public void method named addStudent which takes a Student as a parameter and adds it to the roster. Each time a student is added the roster should be sorted alphabetically by student last name then first name. e. A public void method named removeStudent which takes a String named personId as a parameter and removes any student from the roster who has that personId instance variable. f. A public toString method with no parameters, returning a String which contains all of the following, each on its own line (use ) in the given order: i. The Course ID ii. The Course Name iii. The Course Code iv. A blank line v. The String Instructor vi. The String ------------------------- vii. The results of the instructors toString method. viii. A blank line ix. The String Student Roster x. The String ------------------------- xi. A separate line for each Student object in the roster showing the output of its toString method. 5. Draw any appropriate relationship lines (aggregation/composition, inheritance, and implementation) between these classes.

Program

1. Create the Person, Instructor, Student, and Course classes using your UML diagram and the design requirements as a guide. a. To sort the roster use Collections.sort(roster). If you have implemented Comparable correctly then this method will do all of the necessary sorting work for you. 2. The code to place in your CourseApp main method is provided below. You are welcome to copy and paste it to avoid errors. When run your application output should match the Sample Results exactly Student s1 = new Student(); s1.setPersonId("X00000001"); s1.setFirstName("Steve"); s1.setLastName("Smith"); s1.setMajor("Computer Science"); s1.setGpa(3.49); Student s2 = new Student(); 2.setPersonId("X00000002"); s2.setFirstName("Sally"); s2.setLastName("Smith"); s2.setMajor("History\t\t"); s2.setGpa(2.98); Student s3 = new Student(); s3.setPersonId("X00000003"); s3.setFirstName("Amanda"); s3.setLastName("Adams"); s3.setMajor("Civil Engineering"); s3.setGpa(3.7); Student s4 = new Student(); s4.setPersonId("X00000004"); s4.setFirstName("Timothy"); s4.setLastName("Turner"); s4.setMajor("Biology\t\t"); s4.setGpa(2.51);

Student s5 = new Student(); s5.setPersonId("X00000005"); s5.setFirstName("Thomas"); s5.setLastName("Turner"); s5.setMajor("Nursing\t\t"); s5.setGpa(2.34); Instructor i1 = new Instructor(); i1.setPersonId("X00009876"); i1.setFirstName("Jane"); i1.setLastName("Jones"); i1.setTitle("Associate Professor"); i1.setDepartment("Mathematics"); Instructor i2 = new Instructor(); i2.setPersonId("X00436754"); i2.setFirstName("Wilson"); i2.setLastName("Walton"); i2.setTitle("Lab Instructor"); i2.setDepartment("Biology"); Course c1 = new Course(); c1.setCourseId("10000"); c1.setCourseCode("MATH 101"); c1.setCourseName("College Algebra"); c1.setInstructor(i1); c1.addStudent(s2); c1.addStudent(s3); c1.addStudent(s5); Course c2 = new Course(); c2.setCourseId("21567"); c2.setCourseCode("MATH 111"); c2.setCourseName("Pre-Calculus"); c2.setInstructor(i1); c2.addStudent(s1); c2.addStudent(s4); Course c3 = new Course(); c3.setCourseId("69843"); c3.setCourseCode("BIOL 103"); c3.setCourseName("Biology I Lab"); c3.setInstructor(i2); 3.addStudent(s1); c3.addStudent(s2); c3.addStudent(s3); c3.addStudent(s4); c3.addStudent(s5); System.out.println(c1); System.out.println(); System.out.println(c2); System.out.println(); System.out.println(c3); System.out.println(); c3.removeStudent("X00000002"); System.out.println(c3)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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