I only need help with four methods in the EmployeeManager class the methods are addRequest,
viewNextRequest, grantNextRequest, and outputRequests. I posted all of the other uml for
refernce on items that could be called.
UML DIAGRAM FOR AND DISCUSSION FOR EmptyListException
EmptyListException extends RuntimeException
<>EmptyListException( )
<>EmptyListException(name : String)
Constructors
The constructor that takes a String as an argument calls upon the super class constructor with that
String concatenated with “ is Empty”. The constructor that takes no argument calls upon the
other constructor with the argument of “List”.
This class should belong to the exceptions package.
UML DIAGRAM FOR AND DISCUSSION FOR ListNode
ListNode>
data : E
nextNode: ListNode
<>ListNode(d : E)
<>ListNode(d : E, node : ListNode)
+ setData(d : E)
+getData() : E
+setNext(next : ListNode)
+getNext() : ListNode
Notes on ListNode
ListNode(d : E) sets the nextNode to null, the rest of the implementation of the ListNode class is
self-explanatory as discussed in class
UML DIAGRAM FOR AND DISCUSSION FOR LinkedList
LinkedList>
firstNode : ListNode
lastNode : ListNode
numElements : int
name : String
<>LinkedList()
<>LinkedList(name : String)
+ insertAtFront(item : E)
+ insertAtBack(item : E)
+ removeFromFront() : E throws EmptyListException
+ removeFromBack() : E throws EmptyListException
+ removeItem(index : int) : E throws IndexOutOfBoundsException
+ getItem(index : int) : E throws IndexOutOfBoundsException
+ setItem(index : int, item : E) throws IndexOutOfBoundsException
+ findAndRemove(item : E) : Boolean
+ findItem(item E) : int
+ lengthIs() : int
+ clear()
+ toString()
+ isEmpty() : Boolean
+ sort() throws EmptyListException
Notes on LinkedList
Constructors
Both constructors set firstNode and lastNode to null and numElements to 0. The constructor that
takes a String sets the name data member to the String that is passed
insertAtFront(E)
Inserts the passed item to the front of the list
void insertAtBack(E)
Inserts the passed item in the back of the list
void removeFromFront()
Removes the first item in the list, and returns it. If the list is empty throws a new
EmptyListException with the message: “(Name of list) is Empty”
removeFromBack()
Removes the last item in the list, and returns it. If the list is empty throws a new
EmptyListException with the message: “(Name of list) is Empty”
removeItem(int)
Removes the element from the list at the given index. If that index does not exist within the
LinkedList an IndexOutOfBoundsException is thrown with the message: “(Name of List) Index
out of Range”. Returns the item removed.
getItem(int)
Returns the element at the given index. If that index does not exist within the LinkedList an
IndexOutOfBoundsException is thrown with the message: “(Name of List) Index out of Range”.
public setItem(int index, E item)
Attempts to place the passed item into the given index. If that index does not exist within the
LinkedList an IndexOutOfBound.
MARGINALIZATION (Different learners in Marginalized Group
I only need help with four methods in the EmployeeManager class the .pdf
1. I only need help with four methods in the EmployeeManager class the methods are addRequest,
viewNextRequest, grantNextRequest, and outputRequests. I posted all of the other uml for
refernce on items that could be called.
UML DIAGRAM FOR AND DISCUSSION FOR EmptyListException
EmptyListException extends RuntimeException
<>EmptyListException( )
<>EmptyListException(name : String)
Constructors
The constructor that takes a String as an argument calls upon the super class constructor with that
String concatenated with “ is Empty”. The constructor that takes no argument calls upon the
other constructor with the argument of “List”.
This class should belong to the exceptions package.
UML DIAGRAM FOR AND DISCUSSION FOR ListNode
ListNode>
data : E
nextNode: ListNode
<>ListNode(d : E)
<>ListNode(d : E, node : ListNode)
+ setData(d : E)
+getData() : E
+setNext(next : ListNode)
+getNext() : ListNode
Notes on ListNode
ListNode(d : E) sets the nextNode to null, the rest of the implementation of the ListNode class is
self-explanatory as discussed in class
UML DIAGRAM FOR AND DISCUSSION FOR LinkedList
LinkedList>
firstNode : ListNode
lastNode : ListNode
numElements : int
name : String
<>LinkedList()
<>LinkedList(name : String)
+ insertAtFront(item : E)
+ insertAtBack(item : E)
2. + removeFromFront() : E throws EmptyListException
+ removeFromBack() : E throws EmptyListException
+ removeItem(index : int) : E throws IndexOutOfBoundsException
+ getItem(index : int) : E throws IndexOutOfBoundsException
+ setItem(index : int, item : E) throws IndexOutOfBoundsException
+ findAndRemove(item : E) : Boolean
+ findItem(item E) : int
+ lengthIs() : int
+ clear()
+ toString()
+ isEmpty() : Boolean
+ sort() throws EmptyListException
Notes on LinkedList
Constructors
Both constructors set firstNode and lastNode to null and numElements to 0. The constructor that
takes a String sets the name data member to the String that is passed
insertAtFront(E)
Inserts the passed item to the front of the list
void insertAtBack(E)
Inserts the passed item in the back of the list
void removeFromFront()
Removes the first item in the list, and returns it. If the list is empty throws a new
EmptyListException with the message: “(Name of list) is Empty”
removeFromBack()
Removes the last item in the list, and returns it. If the list is empty throws a new
EmptyListException with the message: “(Name of list) is Empty”
removeItem(int)
Removes the element from the list at the given index. If that index does not exist within the
LinkedList an IndexOutOfBoundsException is thrown with the message: “(Name of List) Index
out of Range”. Returns the item removed.
getItem(int)
Returns the element at the given index. If that index does not exist within the LinkedList an
IndexOutOfBoundsException is thrown with the message: “(Name of List) Index out of Range”.
public setItem(int index, E item)
Attempts to place the passed item into the given index. If that index does not exist within the
LinkedList an IndexOutOfBoundsException is thrown with the message: “(Name of List) Index
3. out of Range”.
findAndRemove(E)
Attempts to find the passed item, if found removes it and returns true, if not returns false
findItem(E)
Attempts to find the passed item, if found returns the location, if not returns -1
lengthIs()
Returns the number of elements in the list
clear()
Removes all elements from the list
public String toString()
Returns a String containing all elements in the LinkedList separated by two new lines.
public void sort()
Sorts the contents of the LinkedList using the Selection Sort. If the list is empty throws a new
EmptyListException with the message: “(Name of list) is Empty”
isEmpty()
Returns true if empty, false if not
Both the ListNode and LinkedList class belong to the dataStructures package.
UML DIAGRAM FOR AND DISCUSSION FOR Queue
Queue>
private LinkedList list
<> Queue()
<> Queue(name : String)
+ enqueue(item : E)
+ dequeue() : E
+ lengthIs() : int
+ peek() : E
+ toString() : String
+ isEmpty() : Boolean
+ clear()
Notes on Queue
The composition technique of Queue is being used. That is, Queue HAS-A LinkedList, as
opposed to the inheritance technique where Queue IS-A LinkedList
The implementation of the methods is as discussed and demonstrated in class.
The Queue belongs to the dataStructures package.
Changes to EmployeeManager
The EmployeeManager is being updated to use LinkedLists to reference the Employees in the
4. ArrayList by sub-type. Changes need to be made where Employees are add/removed to perform
similar actions to the correct LinkedList. Additionally some of the previous methods can be
changed to take advantage of this addition. Since this now uses your LinkedList you must import
it from your dataStructures package.
Additionally, he EmployeeManager is adding a Queue for maintaining Employee vacation
requests. Some methods are being added to provide this new feature. Since this now uses your
Queue you must import it from your dataStructures package (changes in bold).
EmployeeManager
- employees : ArrayList
- employeeMax : final int = 10
- hourlyList : LinkedList
- salaryList : LinkedList
- commissionList : LinkedList
- vacationRequests : Queue
<> EmployeeManager()
+ addEmployee( type : int, fn : String, ln : String, m : char, g : char, en : int, ft : boolean, amount
: double) throws InvalidEmployeeNumberException
+ removeEmployee( index : int)
+ listAll()
+ listHourly()
+ listSalary()
+ listCommision()
+ resetWeek()
+ calculatePayout() : double
+ getIndex( empNum : int ) : int
+ annualRaises()
+ holidayBonuses() : double
+ increaseHours( index : int, amount : double)
+ increaseSales( index : int, amount : double)
+ findAllBySubstring(find : String) : Employee[]
- RabinKarp(name : String, find : String) : int
- stringHash(s : String) : int
- charNumericValue(c : char) : int
- RabinKarpHashes(s : String, hashes : int[], pos : int, length : int) : int
- linearSearchRecursive(nameHashes : int[], findHash : int, pos : int) : int
+ sort()
5. + addRequest(empNum : int) : boolean
+ viewNextRequest() : Employee
+ grantNextRequest() : Employee
+ outputRequests()
Constructor
Create LinkedLists for the new data members. Name the lists (by using the appropriate
constructor) “Hourly List”, “Salary List”, and “Commission List”. Create the Queue object for
the new Queue data member. Name the Queue “Vacation Requests” by using the appropriate
constructor.
View Vacation Requests
Output the current vacation requests using the EmployeeManager’s outputRequests. Then
specifically outputs the next Employee to receive a request if present (see below example for
expected output).
Add Vacation Request
Asks user for the Employee number of the Employee to add to the request queue. If the
Employee exists outputs they have been added to the queue, if not outputs there is no Employee
(see below example for expected output).
Grant Vacation Request
Attempts to grant the next vacation request in the Queue. If it is successful outputs the Employee
that was granted the request, otherwise outputs there were no requests (see below example for
expected output).
EmptyListException extends RuntimeException
<>EmptyListException( )
<>EmptyListException(name : String)
Solution
Added Four New Methods in EmployeeManager.java
Adding Employee.java
public class Employee {
String firstName;
String lastName;
6. int type;
char m;
char g;
int en;
boolean ft;
double amount;
public Employee() {
// TODO Auto-generated constructor stub
}
public Employee(String firstName,String lastName,int type,char m,
char g,
int en,
boolean ft,
double amount) {
// TODO Auto-generated constructor stub
this.firstName = firstName;
this.lastName = lastName;
this.type = type;
this.m = m;
this.g = g;
this.ft = ft;
this.amount = amount;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getType() {
7. return type;
}
public void setType(int type) {
this.type = type;
}
public char getM() {
return m;
}
public void setM(char m) {
this.m = m;
}
public char getG() {
return g;
}
public void setG(char g) {
this.g = g;
}
public int getEn() {
return en;
}
public void setEn(int en) {
this.en = en;
}
public boolean isFt() {
return ft;
}
public void setFt(boolean ft) {
this.ft = ft;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
8. }
=====================================================================
====================
Adding EmployeeManager.java
import java.util.ArrayList;
public class EmployeeManager {
ArrayList list;
ArrayList requests;
public EmployeeManager() {
list = new ArrayList();
requests = new ArrayList();
}
public void addEmployee(String firstName,String lastName,int type,char m,
char g,
int en,
boolean ft,
double amount){
Employee e = new Employee(firstName, lastName, type, m, g, en, ft, amount);
list.add(e);
}
public boolean addRequest(int empNum){
requests.add(empNum);
return true;
}
public Employee viewNextRequest(){
if(requests.size()<=0)
return null;
else{
int num = requests.get(0);
for(int i=0;i