Computers and Technology, 01.12.2021 02:00 140007625
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!
Answers: 3
Computers and Technology, 23.06.2019 14:00
What is html ? give a small description about html
Answers: 2
Computers and Technology, 24.06.2019 02:00
Write an expression that will cause the following code to print "equal" if the value of sensorreading is "close enough" to targetvalue. otherwise, print "not equal". ex: if targetvalue is 0.3333 and sensorreading is (1.0/3.0), output is:
Answers: 1
Computers and Technology, 25.06.2019 08:10
A(n) is a step-by-step direction for performing a specific task, which is written in a language the computer can understand.servercachearrayprogram
Answers: 1
In this exercise, we will be refactoring a working program. Code refactoring is a process to improve...
Mathematics, 18.03.2021 05:20
English, 18.03.2021 05:20
Computers and Technology, 18.03.2021 05:20
Chemistry, 18.03.2021 05:20
English, 18.03.2021 05:20
Mathematics, 18.03.2021 05:20
Mathematics, 18.03.2021 05:20