Design a class named Person and its two subclasses named Studentand Employee. Ma
ID: 3618953 • Letter: D
Question
Design a class named Person and its two subclasses named Studentand Employee. Make Faculty and Staff subclasses of Employee. Aperson has a name, address, phone number, and email address. Astudent has a class status(freshman,sophomore, junior, or senior).Define the status as a constant. An employee has an office, salary,and date-hired. Define a class named MyDate that contains thefields year, month and day.A faculty member has office hours and a rank. A staff member has atitle. Override the toString method in each class to display theclass name and the person's name.
Explanation / Answer
A person has a name, address,phone number, and email address. Override the toString method in each class to display the classname and the person's name. publicclass Person { privateString name, address, phone_number,email_address; //constructors // accessors &modifiers publicString toString() { return getClass().getName()+" "+name; } } A student hasa class status(freshman,sophomore, junior, or senior). Define thestatus as a constant. publicclass Student extendsPerson { privatefinal String class_status; publicStudent(String class_status) { this.class_status =class_status; } // other constructors toset superclass fields publicString getClassStatus() { return class_status; } } Define a class namedMyDate that contains the fields year, month andday. public classMyDate { privateint year, month, day; publicMyDate(int month, int day, intyear) { this.year = year; this.month =month; this.day = day; } } An employee has an office, salary, anddate-hired. publicclass Employee extends Person { privateString office,salary; private MyDate date_hired; //constructors // accessors &modifiers } A faculty member hasoffice hours and a rank. publicclass FacultyMember extends Employee { privateString office_hours, rank; //constructors // accessors &modifiers } A staff member has atitle. publicclass StaffMember extends Employee { privateString title; //constructors publicString getTitle() { return title; } publicvoid setTitle(String title) { this.title =title; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.