Computers and Technology
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!

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 20:20, ab847150
Wireless communications is likely to be viewed as an essential part of an enterprise network infrastructure when: select one: a. mobile communication is needed b. communication facilities must be installed at low initial cost c. communication must take place in a hostile or difficult terrain that makes wired communication difficult or impossible d. the same information must be broadcast to many locations
Answers: 1
image
Computers and Technology, 21.06.2019 21:20, shadowgirl1213
Write a select statement that returns product name, customer first name, customer last name, channel description, and amount sold for all the sales. make sure to returns sales even if there is no information on the customer, product, or channe
Answers: 2
image
Computers and Technology, 22.06.2019 11:00, kingethan08
Ihave an iphone 8plus should i get another phone like samsung note 9 or s9 ? ?
Answers: 2
image
Computers and Technology, 22.06.2019 15:30, alexdub9649
What is a costume plot? why is it important to a film or theater production?
Answers: 2
Do you know the correct answer?
In this exercise, we will be refactoring a working program. Code refactoring is a process to improve...

Questions in other subjects:

Konu
Mathematics, 20.08.2019 21:40