SlideShare a Scribd company logo
1 of 4
Download to read offline
I need help with this one method in java. Here are the guidelines. Only public Employee[]
findAllBySubstring(String find).
EmployeeManager
EmployeeManager
- employees : Employee[]
- employeeMax : final int = 10
-currentEmployees : int
<> EmployeeManager
+ addEmployee( type : int, fn : String, ln : String, m : char, g : char, en : int, ft : boolean, amount
: double)
+ 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
public EmployeeManager()
Constructor, creates the Employee array, sets currentEmployees to 0.
public void addEmployee(int, String, String, char, char, int, Boolean, double)
Takes an int representing the type of Employee to be added (1 – Hourly, 2 – Salary, 3 –
Commission) as well as the required data to create that Employee. If one of these values is not
passed output the line, “Invalid Employee Type, None Added”, and exit the method. If an
Employee with the given Employee Number already exists do not add the Employee and output
the line, “Duplicate Not Added”, and exit the method. If the array is at maximum capacity do not
add the new Employee, and output the line, "Cannot add more Employees".
public void removeEmployee(int)
Removes an Employee located at the given index from the Employee array.
public void listAll()
Lists all the current Employees. Outputs there are none if there are none.
public void listHourly()
Lists all the current HourlyEmployees. Outputs there are none if there are none.
public void listSalary()
Lists all the current SalaryEmployees. Outputs there are none if there are none.
public void listCommission()
Lists all the current CommissionEmployees. Outputs there are none if there are none.
public void resetWeek()
Resets the week for all Employees.
public double calculatePayout()
Returns the total weekly payout for all Employees.
public int getIndex(int)
Given an Employee Number, returns the index of that Employee in the array, if the Employee
doesn’t exist retuns -1.
public void annualRaises()
Applies annual raise to all current Employees.
public double holidayBonuses()
Outputs and returns the total holiday bonus of all Employees.
public void increaseHours(int, double)
Increase the hours worked of the Employee at the given index by the given double amount.
public void increaseSales(int, double)
Increase the sales of the Employee at the given index by the given double amount.
public Employee[] findAllBySubstring(String find)
This method will return an array of all the Employees in the EmployeeManager that contain the
substring passed. Create a new Employee array with the size of the number of current
Employees. For every Employee call upon the RabinKarp method giving the search string as the
concatenation of that Employee’s first and last name (no spaces). If the substring is found in the
Employee add that Employee to the new array. After all have been checked, return the array.
private int charNumericValue(char c)
Given a character, returns the numeric value of the character, starting with A – 0 up to Z – 25.
This should treat upper and lower case the same; that is passing it ‘A’ will return 0, passing it ‘a’
will also return 0. If a letter is not passed this method should create and throw an
InvalidCharacterException as provided.
private int stringHash(String s)
Given a string, return the hash value of the entire String. Use a base 26 number system to create
the hash as described in class. This will be needed only to find the hash of the substring that is
being searched for and the base case for finding all substring hashes in the search string.
private int RabinKarpHashes(String s, int[] hashes, int pos, int length)
Finds the hash values of all substrings of size length in the String s, starting at index pos and
down. These values are stored in the passed hashes array. This method must be recursive, using
the technique as described in the Rabin-Karp lecture.
private int linearSearchRecursive(int[] data, int key, int pos)
This is a recursive linear search. Return the position of key in the data array, or -1 if it is not
present. This method must be recursive.
private int RabinKarp(String name, String find)
Does the preprocessing of finding the hash for the substring, find using the stringHash method
and the hashes of substrings in the search string using RabinKarpHashes method. Calls upon
linearSearchRecursive to determine if the substring hash is in the collection of hashes and returns
the result.
EmployeeManager
- employees : Employee[]
- employeeMax : final int = 10
-currentEmployees : int
<> EmployeeManager
+ addEmployee( type : int, fn : String, ln : String, m : char, g : char, en : int, ft : boolean, amount
: double)
+ 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
Solution
employees[] = new Employee[employeeMax];
/**** HourlyEmployee is a subclass of superclass Employee. Here's my code . *******/

More Related Content

Similar to I need help with this one method in java. Here are the guidelines. O.pdf

Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
aathmaproducts
 
package employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfpackage employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdf
nipuns1983
 
9781439035665 ppt ch09
9781439035665 ppt ch099781439035665 ppt ch09
9781439035665 ppt ch09
Terry Yoast
 
Underscore.js
Underscore.jsUnderscore.js
Underscore.js
timourian
 
There are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdfThere are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdf
aamousnowov
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
Masudul Haque
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
Eelco Visser
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
info114
 

Similar to I need help with this one method in java. Here are the guidelines. O.pdf (20)

Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
 
[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types
 
Advance excel
Advance excelAdvance excel
Advance excel
 
Python : Functions
Python : FunctionsPython : Functions
Python : Functions
 
package employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfpackage employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdf
 
9781439035665 ppt ch09
9781439035665 ppt ch099781439035665 ppt ch09
9781439035665 ppt ch09
 
PYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptxPYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptx
 
Underscore.js
Underscore.jsUnderscore.js
Underscore.js
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java Programmers
 
Data Handling
Data Handling Data Handling
Data Handling
 
There are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdfThere are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdf
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
 
Array Cont
Array ContArray Cont
Array Cont
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
 
Python programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsPython programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operations
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
 
Day2
Day2Day2
Day2
 
Rethink programming: a functional approach
Rethink programming: a functional approachRethink programming: a functional approach
Rethink programming: a functional approach
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
 

More from arihantmum

help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
arihantmum
 
Couldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfCouldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdf
arihantmum
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdf
arihantmum
 
classify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfclassify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdf
arihantmum
 
Compare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfCompare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdf
arihantmum
 
B. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfB. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdf
arihantmum
 
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfAssume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
arihantmum
 
As late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfAs late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdf
arihantmum
 
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
arihantmum
 
1. An important contribution of Fiedlers research on the contingen.pdf
1. An important contribution of Fiedlers research on the contingen.pdf1. An important contribution of Fiedlers research on the contingen.pdf
1. An important contribution of Fiedlers research on the contingen.pdf
arihantmum
 

More from arihantmum (20)

In 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdfIn 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdf
 
In a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdfIn a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdf
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
 
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdfHeading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
 
Explain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdfExplain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdf
 
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdfExplain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
 
Couldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfCouldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdf
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdf
 
Describe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdfDescribe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdf
 
classify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfclassify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdf
 
Compare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfCompare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdf
 
B. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfB. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdf
 
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfAssume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
 
Amon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdfAmon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdf
 
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdfA box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
 
As late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfAs late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdf
 
A bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdfA bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdf
 
Xavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdfXavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdf
 
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
 
1. An important contribution of Fiedlers research on the contingen.pdf
1. An important contribution of Fiedlers research on the contingen.pdf1. An important contribution of Fiedlers research on the contingen.pdf
1. An important contribution of Fiedlers research on the contingen.pdf
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
Elizabeth Walsh
 

Recently uploaded (20)

How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Ernest Hemingway's For Whom the Bell Tolls
Ernest Hemingway's For Whom the Bell TollsErnest Hemingway's For Whom the Bell Tolls
Ernest Hemingway's For Whom the Bell Tolls
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 

I need help with this one method in java. Here are the guidelines. O.pdf

  • 1. I need help with this one method in java. Here are the guidelines. Only public Employee[] findAllBySubstring(String find). EmployeeManager EmployeeManager - employees : Employee[] - employeeMax : final int = 10 -currentEmployees : int <> EmployeeManager + addEmployee( type : int, fn : String, ln : String, m : char, g : char, en : int, ft : boolean, amount : double) + 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 public EmployeeManager() Constructor, creates the Employee array, sets currentEmployees to 0. public void addEmployee(int, String, String, char, char, int, Boolean, double) Takes an int representing the type of Employee to be added (1 – Hourly, 2 – Salary, 3 – Commission) as well as the required data to create that Employee. If one of these values is not passed output the line, “Invalid Employee Type, None Added”, and exit the method. If an Employee with the given Employee Number already exists do not add the Employee and output
  • 2. the line, “Duplicate Not Added”, and exit the method. If the array is at maximum capacity do not add the new Employee, and output the line, "Cannot add more Employees". public void removeEmployee(int) Removes an Employee located at the given index from the Employee array. public void listAll() Lists all the current Employees. Outputs there are none if there are none. public void listHourly() Lists all the current HourlyEmployees. Outputs there are none if there are none. public void listSalary() Lists all the current SalaryEmployees. Outputs there are none if there are none. public void listCommission() Lists all the current CommissionEmployees. Outputs there are none if there are none. public void resetWeek() Resets the week for all Employees. public double calculatePayout() Returns the total weekly payout for all Employees. public int getIndex(int) Given an Employee Number, returns the index of that Employee in the array, if the Employee doesn’t exist retuns -1. public void annualRaises() Applies annual raise to all current Employees. public double holidayBonuses() Outputs and returns the total holiday bonus of all Employees. public void increaseHours(int, double) Increase the hours worked of the Employee at the given index by the given double amount. public void increaseSales(int, double) Increase the sales of the Employee at the given index by the given double amount. public Employee[] findAllBySubstring(String find) This method will return an array of all the Employees in the EmployeeManager that contain the substring passed. Create a new Employee array with the size of the number of current Employees. For every Employee call upon the RabinKarp method giving the search string as the concatenation of that Employee’s first and last name (no spaces). If the substring is found in the Employee add that Employee to the new array. After all have been checked, return the array. private int charNumericValue(char c) Given a character, returns the numeric value of the character, starting with A – 0 up to Z – 25. This should treat upper and lower case the same; that is passing it ‘A’ will return 0, passing it ‘a’
  • 3. will also return 0. If a letter is not passed this method should create and throw an InvalidCharacterException as provided. private int stringHash(String s) Given a string, return the hash value of the entire String. Use a base 26 number system to create the hash as described in class. This will be needed only to find the hash of the substring that is being searched for and the base case for finding all substring hashes in the search string. private int RabinKarpHashes(String s, int[] hashes, int pos, int length) Finds the hash values of all substrings of size length in the String s, starting at index pos and down. These values are stored in the passed hashes array. This method must be recursive, using the technique as described in the Rabin-Karp lecture. private int linearSearchRecursive(int[] data, int key, int pos) This is a recursive linear search. Return the position of key in the data array, or -1 if it is not present. This method must be recursive. private int RabinKarp(String name, String find) Does the preprocessing of finding the hash for the substring, find using the stringHash method and the hashes of substrings in the search string using RabinKarpHashes method. Calls upon linearSearchRecursive to determine if the substring hash is in the collection of hashes and returns the result. EmployeeManager - employees : Employee[] - employeeMax : final int = 10 -currentEmployees : int <> EmployeeManager + addEmployee( type : int, fn : String, ln : String, m : char, g : char, en : int, ft : boolean, amount : double) + removeEmployee( index : int) + listAll() + listHourly() + listSalary() + listCommision() + resetWeek() + calculatePayout() : double + getIndex( empNum : int ) : int + annualRaises() + holidayBonuses() : double + increaseHours( index : int, amount : double)
  • 4. + 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 Solution employees[] = new Employee[employeeMax]; /**** HourlyEmployee is a subclass of superclass Employee. Here's my code . *******/