subject

In this exercise, we will be refactoring a working program. Code refactoring is a process to improve an existing code in term of its internal structure without changing its external behavior. In this particular example, we have three classes Course, Student, Instructor in addition to Main. All classes are well documented. Read through them to understand their structure. In brief, Course models a course that has a title, max capacity an instructor and students. Instructor models a course instructor who has a name, id and salary. Student models a student who has a name, id, and credits. The Main class create hypothetical instructor, students and course and calls the method print in each object to format the output (see below).
Hani Javadi, instructor ID: 888777666, salary: 11111.0
--- --- ---
Joe Loop, student ID: 810123456, credits: 10
--- --- ---
Mary Collection, student ID: 811987321, credits: 25
--- --- ---
Ke Method, student ID: 810010101, credits: 0
--- --- ---
MIST 4700 MWF 6am-7am
Instructor: Hani Javadi Room: Z101
Class list:
Joe Loop, student ID: 810123456, credits: 10
Mary Collection, student ID: 811987321, credits: 25
Ke Method, student ID: 810010101, credits: 0
Number of students: 3
This program is working and fully functional. However, there is a substantial code duplication between Student and Instructor. Your job is to eliminate this redundancy and improve the program structure by following these steps:

Make both Student and Instructor subclasses of Person
Move the common attributes (name & id) from Instructor & Student to Person
Move the common methods getName, setName, getID, setID, getLoginName to Person
Create a method print() in Person, in this method print the name of the person: System. out. print(name);
Modify the methods print() in Student and Instructor by making them
Call super. print()
Then printing the IDs, credits and salary respectively
Effectively the super class Person will take care of printing name, then the subclasses will provide the added functionality of displaying ID and credits (Student) and salary (Instructor)

The Main and Course classes should compile and work as usual at this point producing exactly same output as above. Happy refactoring!

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:30
The total revenues for a company are $150,223 and the total expenses were 125,766. if you are calculating the net income, which of these spreadsheets would you use? insert a spreadsheet with $150,223 in cell b2 and 125, 766 in cell b3. enter a formula =b2-b3. the formula should be showing in the formula bar. insert a spreadsheet with $150,223 in cell b2 and 125, 766 in cell b3. enter a formula =b2+b3. the formula should be showing in the formula bar. insert a spreadsheet with $150,223 in cell b2 and 125, 766 in cell b3. enter a formula =b2/b3. the formula should be showing in the formula bar. insert a spreadsheet with $150,223 in cell b2 and 125, 766 in cell b3. enter a formula =b2*b3. the formula should be showing in the formula bar.
Answers: 3
question
Computers and Technology, 22.06.2019 15:00
I'm taking a class on how to make a movie, and it offers some apps that would be in the process. the thing is, i don't have any of those ha. if you have any tips on some apps i could use, that would be awesome. i don't have an iphone, so don't suggest any apps like imovie. i know that this is a weird question, but it would be super for me. : )
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
How should you specify box sizes on a web page if you want the boxes to vary according to the font size of the text they contain? a. in pixels b. in inches c. as percentages d. in em units
Answers: 2
question
Computers and Technology, 23.06.2019 15:00
In the blank libreoffice writer document, to start the process of entering a date field into a letter, click on the insert menu. edit menu. file menu. fields menu.
Answers: 3
You know the right answer?
In this exercise, we will be refactoring a working program. Code refactoring is a process to improve...
Questions
question
English, 22.07.2019 05:10
question
English, 22.07.2019 05:10
question
Mathematics, 22.07.2019 05:10
question
English, 22.07.2019 05:10
Questions on the website: 13722363