67.2k views
5 votes
In java

Faculty extends Employee
coursesTaught: Course[ ] // you can assume that the maximum number of courses a facult // taught cannot exceed 100
numCoursesTaught: int //controlled variable
isTenured: boolean
Faculty() // coursesTaught = [], numCoursesTaught = 0, isTenured = false
Faculty(boolean isTenured) // coursesTaught = [], numCoursesTaught = 0, this.isTenured = isTenured
Faculty(String deptName, boolean isTenured)
Faculty(String name, int birthYear, String deptName, boolean isTenured)
isTenured():boolean
getNumCoursesTaught(): int
setIsTenured(boolean isTenured): void
addCourseTaught(Course course): void //appends course to the end of the existing array
addCoursesTaught(Course [] course): void //appends courses to the end of the existing array
getCourseTaught(int index): Course // note: index must be verified. Return "null" if invalid
getCourseTaughtAsString(int index): String // note: index must be verified. Return "" if invalid // returns "courseDept-courseNum"
getAllCoursesTaughtAsString(): String // comma separated list of all courses taught // uses getCourseTaughtAsString(int index) as a helper method
equals(Object obj): boolean //all attributes inhereted+local must match for 2 Faculty objects to be considered equal
toString(): String //" Faculty: %11s | Number of Courses Taught: %3d |
Courses Taught: %s", Is Tenured/Not Tenured , numCoursesTaught,
getAllCoursesTaughtAsString()
compareTo(Person p): int // use the Comparable interface specification, sort by // numCoursesTaught

User Seeker
by
8.5k points

1 Answer

1 vote

Final answer:

The question involves creating a Java class Faculty with specific attributes and methods, emphasizing OOP principles such as inheritance and encapsulation.

Step-by-step explanation:

The student's question pertains to implementing a Java class Faculty which extends another class named Employee.

The Faculty class includes attributes such as coursesTaught (an array of Course objects), numCoursesTaught (an integer tracking the number of courses taught), and isTenured (a boolean indicating tenure status).

Additionally, constructors and multiple methods are specified, including getters and setters for these attributes, methods for adding courses to the coursesTaught array, and methods for converting course information to a string format.

This description also outlines an equals method for comparing two Faculty objects and a compareTo method as specified by the Comparable interface.

The implementation requires consideration of object-oriented programming (OOP) principles such as inheritance, encapsulation, and potentially polymorphism (for the compareTo method).

User Neven Subotic
by
8.4k points