Project 3
Administrative Details
Due Date: Friday, October 27, 2006 at 11:59pm
Points: 70 points possible. 25% of the points taken off each day late.
Project Description
Your assignment is to create a "Employees" class and modify the "Person" class from project 1. I strongly suggest you modify the "Person" class first and test its functionality before starting on the "Employees" class.
Details:
- If you do not trust that your Person class was 100% correct, you can start off with my version. You can download my "Person.java" from here.
- If you do not trust that your Birthday class was 100% correct, you can start off with my version. You can download my "Birthday.java" from here.
Person class modification
- Your Person class should be changed in the following ways:
- Delete the data field "name".
- Delete the setName method.
- Delete the getName method.
- Add a data field for "last name" - which is a String.
- Add a data field for "first name" - which is a String.
- Add a data field for "salary" - which is an int.
- Add a data field for "birthday" - which is a Birthday object.
- Change the constructor to have two argements: a String and an int. The String is the name of the person and the int is the salary. Note that the "name" will comprise a name with the following format: "last, first" - you must parse the name into two different strings and store them sepeartely as the "last name" and "first name" variables. This constrcutor creates the "birthday" instance variable and passes the Birthday constructor no arguments. (The birthday should, therefore, default to 1-1-2001.)
- Create a constructor that has three argements: a String (name), an int (salary), and a Birthday object (birthday). The passed Birthday object is the birthday of the person. Like the first constructor, you must parse the name variable into last and first names. The format will remain the same as "last, first".
- Create a constructor that has five argements: a String (name), an int (salary), an int (day), an int (month), and an int (year). The "birthday" instance variable should be created with the appropriate day, month, and year values. Like the first constructor, you must parse the name variable into last and first names. The format will remain the same as "last, first".
- Add a "setSalary" method that takes an int and changes the salary of the person.
- Add a "getSalary" method that takes no arguments and returns the salary of the person.
- Add a "setLastName" method that takes one String and changes the last name of the person.
- Add a "setFirstName" method that takes one String and changes the first name of the person.
- Add a "getLastName" method that takes no arguments and returns the last name of the person.
- Add a "getFirstName" method that takes no arguments and returns the first name of the person.
Employee class
- This Employees class must be named "Employees" - note the capital "E." If your class is titled "employees" the automatic grader will give you a zero for the project.
- Your Employees class must have the following constructors:
- A constructor that takes no arguments. The constructor should create an array of size 10 of type Person (see the data fields description).
- A constructor that takes one argument: an int. This int is the length of the number of employees. The construction should create an array of the designated length of type Person.
- Your Employees class must have the following methods:
- A "addPerson" method that takes a single argument: a Person object and returns true for successfully adding a person and false for failing to add ther person.
- This method should add the Person object to the array of Person objects at the next available location in the array. If there was room then the method should return true after successfully adding the person
- For example, if the array had just been created in the constructor but is empty, then the Person object would be added at the zero position in the array.
- Another example: if the array has three Person objects already then the passed Person object would be added to the third position so that there are four objects in the array.
- If the array is full (for example the length of the array is 10 and the array has 10 Person objects) then the Person should not be added and the method should return false.
- A "findHighestSalary" method that takes no arguments and returns an int (the highest salary). If the array of of Person objects is empty then a "-1" should be returned. Otherwise, the highest salary of the Person objects should be returned.
- A "findLowestSalary" method that takes no arguments and returns an int (the lowest salary). If the array of of Person objects is empty then a "-1" should be returned. Otherwise, the lowest salary of the Person objects should be returned.
- A "findLastName" method that takes one argument: a String (the last name) and returns a boolean. If the last name exists in the array of of Person objects then "true" should be returned. Otherwise, "false" should be returned.
- A "findFirstName" method that takes one argument: a String (the first name) and returns a boolean. If the first name exists in the array of of Person objects then "true" should be returned. Otherwise, "false" should be returned.
- A "findName" method that takes one argument: a String (the name) and returns a boolean. The name will be formatted as "first last". If the name exists in the array of of Person objects then "true" should be returned. Otherwise, "false" should be returned.
- Your Employees class may have as many variables as you deem useful. However, it must have the following data fields:
- An array of Person objects.
How to submit
Web-Cat is not ready for submissions yet.
You should be able to submit just your Person class (submit the Person and Birthday classes together) to test that that part of the assigment works before you submit your entire assignment (Employees, Person, and Birthday classes).
You may submit as many times as you want. There are two ways to submit this project:
- Submit through BlueJ. The lab machines are configured to automatically submit to Web-Cat - the automatic grader. To do so perform the following steps:
- Open BlueJ on one of the lab machines.
- Open your project. You should see your "Person" class displayed as a rectangle.
- Before submitting make sure that your class compiles.
- To submit: Click on the "Tools" menu. Under "Tools" click on "Submit...". Choose CS 1054 and Project 1.
- Submit manually through the Web-Cat website
- Zip your files (Employees, Person, and Birthday java files) together. To do this highlight both of java files in Windows Explorer (note this in not Internet Explorer - this is the file viewer) and right click on one of the files. Select the menu "Send To" and then select "Compressed (zipped) Folder". This will created a new file that ends in ".zip". It will be named either "Person.zip" "Employees.zip" or "Birthday.zip".
- Go to http://web-cat.cs.vt.edu/Web-CAT/WebObjects/Web-CAT.woa.
- Log in using your user name and password that you use for Webmail and Hokie Spa.
- Click on the "Submit" tab. It can be located at the top left of the webpage.
- Select CS 1054 (the CRN may be wrong) then click "Next".
- Select "Project 1" then click "Next".
- Click the "Browse..." button. Browse to your ".zip" file (whereever on your local machine the file is) to upload it. Select your ".zip" file (e.g. "Employees.zip"). Click "Open."
- Click "Next."
- If your file uploaded and the correct files are shown (e.g. Person.java, Birthday.java, and Employees.java) correctly click "Next."
- Wait for the automatic grader to grade your project to see your score.
If you find typoes or the wording is unclear please email me. -- Dr. Ball