Create and work with interfaces
Due Date: Monday of Week 3
10 points
In this lab, you'll create and implement the DepartmentConstants interface presented in this chapter. You'll also create and implement an interface named Displayable that's similar to the Printable interface.
Create the interfaces
- Add an interface named DepartmentConstants that contains the three constants. Compile the interface.
Add an interface named Displayable. This interface should contain a single method named getDisplayText that returns a String. Compile this interface.
Implement the interfaces
Edit the Product class so it implements the Displayable interface. The getDisplayText method in this class should format a string that can be used to display the product information. When you're done, compile this class.
Edit the Employee class so it implements the DepartmentConstants and Displayable interfaces. The getDisplayText method in this class should work like the one in the Product class, and it should use the constants in the DepartmentConstants interface to include the department name in the return value. When you're done, compile this class.
Use the classes that implement the interfaces
Display the DisplayableTestApp class.
Add code to this class that creates an Employee object, assigns it to a Displayable variable, and displays the information in the Employee object at the console. To get the information for an employee, you'll need to use the getDisplayText method of the Displayable interface.
Compile and run the application to make sure that it displays the employee information.
Repeat steps 6 and 7 for a Product object.
Include in your program the following comments:
- Name of program
- Team's name with all the names of the members (e.g. Team A: John Doe, Jane Smith, etc.)
- Current Date
- Computer system and compiler you are using
- Brief description of the program
Compile and run the Java program.
When you are ready, upload the java program by clicking the link below:
Upload Lab
I cannot grade if I don't get the file and receive your email.