Due date: Thursday March 4th, 11:59pm by e-mailFor this assignment you will need to write three programs.
1. Paying Staff Members Example
Write the code for a hierarchy of classes that classifies staff members.
There should be a class
Staff_Member that serves as the
root of the hierarchy.
The rest of the hierarchy should be designed based on the following:
Volunteers do not get paid, they are not considered to be
Employees. However, they share many common characteristics with employees, such as
username, and tele
Employees get paid and they have a
pay_ratewhich is the amount that they get on pay day (their salary).
Employees two categories have
additional features as far as pay is concerned:
Executives the pay is the regular salary plus a one time bonus.
Hourlyemployees the pay is computed by multiplying the number of hours worked with the pay rate.
Additional help with problem 1.
2. Write Your Own Vector Class
Define your own
Vector class then use the
class defined in class, that relies on
Vector, to test your code.
(No longer import
java.util in your test program, instead use the
Vector class you define.)
Vector objects should be able to respond to the
void addElement (Object obj)
- Adds the object to the end of the vector, increasing its size by one.
boolean contains (Object obj)
trueif the object is among the values stored in the vector, or
Object elementAt (int index)
- Returns the object at the specified index position.
int indexOf (Object obj)
- Returns the index position of the first instance of the object in the vector (if the object is in the vector) or
int indexOf (Object obj, int index)
- Same as above, but starts the search from the specified index.
void insertElementAt(Object obj, int index)
- Inserts the object at the specified index position, after shifting down objects at and below the insertion point.
boolean isEmpty ()
trueif the vector contains no objects, or
void removeElement (Object obj)
- Removes the first occurrence of the specified object, and then shifts up objects at and below the deletion point.
void removeElementAt(int index)
- Deletes the object at the specified index position, and then shifts up objects at and below the deletion point.
void setElementAt (Object obj, int index)
- Replaces the existing object at the specified index position with the specified object.
int size ()
- Returns the number of objects currently stored in the vector.
HELP in getting started writing
3. Recursive Calculator
Define a class
If we ever need to specify more details on this problem we
will add a link to the document that provides them here.
Calculator whose instances will be able to
compute (recursively) the nth element of each of the following
T(n) = 2 * T(n-1) + 1, for n > 0
C(n) = 1 + C(n / 2), for n even and
C(n) = 1 + C(3 * n + 1), for n odd
J(n) = 2*J(n/2) - 1, if n > 1 is even, and
J(n) = 2*J((n-1)/2) + 1, if n > 1 is odd
If you have any questions please let us know.
If we ever need to specify more details on this problem we will add a link to the document that provides them here.