Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CS 212- Lab 2 Create a Java project with the classes specified in Inheritance & Polymorphism.pdf. Create an interface called Comparable with a method called
CS 212- Lab 2 Create a Java project with the classes specified in Inheritance & Polymorphism.pdf. Create an interface called Comparable with a method called compareTo. The Employee class should implement this interface public interface Comparable f int compareTo(Object o); In the Staff and Faculty classes, implement the compareTo method from the ble interface. The compareTo method compares this Object with another bject. It returns a negative integer, zero, or a positive integer if this Object is less than, equal to, or greater than, the other Object. Compare the pay between each Object. The argument passed in can be either a Staff object OR a Faculty object. Thus, make sure that it is possible to compare a Staff object to a Faculty object by pay What happens if you implement the compareTo method in the Employee class rather than the Staff and Faculty classes? Modify the email method in the Person class as follows: Create an email address with the person's first initial and last name followed by @qc.cuny.edu Example: JDoe@qc.cuny.edu DO NOT MODIFY any other code than the email() method in the Person class. There is no need to add instance variables and change the constructor. Hint: Use the split() method to split a string into substrings. Use the charAtfint index) method to retrieve the first character of the first name. Add the missing accessor and mutator methods to the classes. In the InheritanceApp, make sure the correct information for each employee is displayed. Compare Mary Smith to Dave Watson; the result should show the employee with the higher pay CS 212- Lab 2 Create a Java project with the classes specified in Inheritance & Polymorphism.pdf. Create an interface called Comparable with a method called compareTo. The Employee class should implement this interface public interface Comparable f int compareTo(Object o); In the Staff and Faculty classes, implement the compareTo method from the ble interface. The compareTo method compares this Object with another bject. It returns a negative integer, zero, or a positive integer if this Object is less than, equal to, or greater than, the other Object. Compare the pay between each Object. The argument passed in can be either a Staff object OR a Faculty object. Thus, make sure that it is possible to compare a Staff object to a Faculty object by pay What happens if you implement the compareTo method in the Employee class rather than the Staff and Faculty classes? Modify the email method in the Person class as follows: Create an email address with the person's first initial and last name followed by @qc.cuny.edu Example: JDoe@qc.cuny.edu DO NOT MODIFY any other code than the email() method in the Person class. There is no need to add instance variables and change the constructor. Hint: Use the split() method to split a string into substrings. Use the charAtfint index) method to retrieve the first character of the first name. Add the missing accessor and mutator methods to the classes. In the InheritanceApp, make sure the correct information for each employee is displayed. Compare Mary Smith to Dave Watson; the result should show the employee with the higher pay
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started