Overview
This is a modified version of the applet created in the previous project.. In a single source file (App.java), define an enhanced Employee class that will throw various exceptions if an attempt is made to store bad data, a custom MyLabel class that encapsulates the processing of a customized Label component, and an App class defining an applet to maintain a collection of Employee objects.
Employee Class
Define a small, non-public class named Employee that encapsulates private instance variables for name (String) and pay rate (double). The class needs a single constructor to instantiate an Employee object with values received for both instance variables. It also needs set() and get() methods (such as setName(), getPayRate(), etc.) that allow a class client to store and retrieve the value of each instance variable. If an attempt is made to store a null name or a pay rate that is less than zero, the corresponding "set" method must throw an Exception object having an appropriate error message. To enforce these edits during construction, the class constructor should call the "set" methods and re-throw any Exception object that may be caught.
Code this class inside your App.java source file but after the definition of the App class. Be sure to omit the specification of public in the class header (because Java only allows one public class per source file).
MyLabel Class
Define a small, non-public class named MyLabel that encapsulates a customized Label component. It should extend the Label class and implement the Runnable interface in order to be run as a thread. A MyLabel object must display text that changes its color and font at a specified interval. The class requires a single constructor that receives a String representing the text to be displayed and an int representing the interval in milliseconds. Provide instance methods to "set" a new value for the text being displayed and the interval in milliseconds. If an attempt is made to set a null text or an interval that is less than zero, the corresponding "set" method must throw an Exception object having an appropriate error message. To enforce these edits during construction, the class constructor should call the "set" methods and re-throw any Exception object that may be caught.
Code this class inside your App.java source file but after the definition of the App class. Be sure to omit the specification of public in the class header (because Java only allows one public class per source file).
App class
This public class will define the processing of your applet. Its required features are as follows:
Input Components:
Name (a TextField). For entering or displaying an employee's name.
Pay rate (a TextField). For entering or displaying an employee's pay rate. When used for input, the only edit that must be directly performed by the application is to verify that the pay rate does not exceed that of the HTML "maxRate" parameter (see below).
First (a button). When clicked, triggers the display of the name and pay rate of the first employee in the collection. If the collection is empty, display an appropriate message.
Next (a button). When clicked, triggers the display of the name and pay rate of the next employee in the collection. If there are no more objects in the collection, display an appropriate message.
Find (a button). When clicked, triggers the display of the name and pay rate of the employee whose name currently appears in the name text field. If the requested employee doesn't exist, display an appropriate error message.
Add (a button). When clicked, triggers the construction of an Employee object having the currently displayed name and pay rate and the addition of the object to the collection. Be sure to process any Exception object that might be thrown (see below) during construction of the Employee object.
Delete (a button). When clicked, triggers the deletion of the Employee object having the currently displayed name from the collection. If the specified employee doesn't exist, display an appropriate error message.
Output components:
Number of employees (a MyLabel). For displaying how many Employee objects are currently within the collection. This must be changed as employees are added or deleted from the collection.
Message area (a TextArea). For displaying messages.
Processing notes:
The applet must get the value of an HTML parameter named "maxRate". Convert the associated value string to a double and use it to edit a pay rate entered by the user. It represents the maximum allowable pay rate for an employee. If an attempt is made to enter a larger pay rate, display an appropriate error message.
Use GridBagLayout for the applet's components. The arrangement of components is up to you.
Use a SortedMap implemented as a TreeMap for the collection. It is to be maintained in ascending order based upon employee name.
When the user moves the mouse to touch one of the buttons, its color or font should change. When the mouse exits the button, its color or font should return to normal.
As an aid in formatting the employee's pay rate, you may use the moneyFormat() method of my Utility class. For more information, consult the documentation for my Utility class.
Code all required try and catch blocks. If an Exception object is caught, display its message in the message area.
You are free to choose colors, fonts, and arrangement of components. Be creative, but make the applet visually appealing and easy to run.
Grading criteria
Your program will be worth 30 points to be awarded as follows:
Accuracy (20 points). The program should correctly perform all specified processing.
Creativity (5 points). The program should be original yet simple in design.
Maintainability (5 points). The program should contain useful comments, meaningful identifiers, and be logically structured. It should contain an opening documentation block with your name and a brief description of what the program does. It should also have a block of comments preceding every major section of code.
Submission
Send your App.java source file as an e-mail document or attachment no later than midnight on the program due date. If you are using JBuilder 4 and the Test project previously copied from the College of Business network, this file will be in the src folder of the project. In the College of Business labs, the complete path of your source file is:
D:\Test\src\App.java
To verify that you are doing this properly, send a copy to yourself, copy the source code to your test project, and re-test the program. If it works for you, it will probably work for me.
Upon receipt of your e-mail, I will send either a verification message or your project score and comments (based on the above criteria). Project scores will be posted on the Internet within a few days after the due date.