The class diagram for the current implementation of the

Added on -2019-09-22

| 29 pages
| 2910 words
| 320 views

Trusted by 2+ million users,
1000+ happy students everyday

Showing pages 1 to 6 of 29 pages

a)The class diagram for the current implementation of the university systemSchoolStudent String schoolNameArrayList <Student> studentsArrayList <Faculty> facultyArrayList <OfficeStaff> o_staff ArrayList <TechnicalSupportStaff> ts_staffString firstName;String lastName;String major;double gpa;String academicLevel;School(String name)addstudent(Student s)addfaculty(Faculty f)addofficeStaff(OfficeStaff os)addTSS(TechnicalSupportStaff tss)displaySchoolInfo()Student(String fName,String lName, String al,String m, double gp)viewStudent()
FacultyString firstNameString lastNameString departmentString researchAreadouble monthly_salaryboolean hourlyPaiddouble hourlyRateOfficeStaffString firstName;String lastName;boolean hourlyPaid;double hourlyRate;double monthly_salary;OfficeStaff(String fName,String lName, boolean hp,double ms, double hr)viewOfficeStaff()Faculty(String fName, String lName, Stringdep, String res, boolean hp, double ms,double hr)viewFaculty()TechnicalSupportStaffString firstName;String lastName;String technicalArea;boolean hourlyPaid;double hourlyRate;double monthly_salary;TechnicalSupportStaff(String fName, StringlName, String ta, boolean hp, double ms,double hr)viewTechnicalSupportStaff()
b) Current implementation violates some of the OO design issues discussed in the class. What are the drawbacks of the design given? How can you refactor it? Here are some of the factors you need to consider Proper data and method abstraction Information hiding Using inheritance and polymorphism as needed Removing duplicate code Other “smelly code” symptoms discussed in the class as appropriateAns : The drawbacks of the given design are:There is no proper formatting of the codeIt violates the DRY (don't repeat yourself)means don't write duplicate code, instead use Abstraction and inheritance to abstract common things in one place.The benefit of this Object oriented design principle is in maintenance. It's important not to abuse it, duplication is not for code, but for functionality.We can remove unused imports Like we can remove import java.util.*; from university.javaThere are no getter and setter for the private fields in every class.
We can refactor it byProper data and method abstraction Information hiding proper formatting of the codeUsing inheritance and polymorphism as needed Removing duplicate codeWe can also write a base class Person.javapackage university;public class Person { protected String firstName; protected String lastName; protected boolean hourlyPaid; protected double hourlyRate; protected double monthly_salary; public String getFirstName() {
return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public boolean isHourlyPaid() { return hourlyPaid; } public void setHourlyPaid(boolean hourlyPaid) { this.hourlyPaid = hourlyPaid; }
public double getHourlyRate() { return hourlyRate; } public void setHourlyRate(double hourlyRate) { this.hourlyRate = hourlyRate; } public double getMonthly_salary() { return monthly_salary; } public void setMonthly_salary(double monthly_salary) { this.monthly_salary = monthly_salary; }}

Found this document preview useful?

You are reading a preview
Upload your documents to download
or
Become a Desklib member to get accesss

Students who viewed this