Programming just give the best example you can on this progr

Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions.

EmployeeManager
EmployeeManager
- employees : Employee[]
- employeeMax : final int = 10
-currentEmployees : int
<<constructor>> 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 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.

Other Notes:
•   Classes from the previous assignment will retain the same package structure. The new Exception is declared to be in its own package called “exceptions”.
•   Your EmployeeManager must import the InvalidCharacterException in order to use it
• Must use rolling hashes like hash(\"BCD\" = 26 x (28 - 0x26^2) +3 but four characters

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

import employeeType.employee.Employee;
import employeeType.subTypes.CommissionEmployee;
import employeeType.subTypes.HourlyEmployee;
import employeeType.subTypes.SalaryEmployee;

public class EmployeeManager {
   Employee[] employees;
   final int employeeMax = 10;
   int currentEmployees;

   public EmployeeManager() {
       // TODO Auto-generated constructor stub

       employees = new Employee[employeeMax];
       this.currentEmployees = 0;
   }

   /*
   * 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 addEmployee(int input, String firstName, String lastName,
           char middleInitial, char gender, int employeeNum, boolean fulltime,
           double wage) {

       switch (input) {
       case 1: {
           HourlyEmployee employee = new HourlyEmployee(firstName, lastName,
                   middleInitial, gender, employeeNum, fulltime, wage);
           for (int i = 0; i < employees.length; i++) {
               if (employees[i].getEmployeeNumber() == employeeNum) {
                   System.out.println(\"Duplicate Not Added\");
                   return;

               }
           }
           if (currentEmployees == employeeMax) {
               System.out.println(\"Cannot add more Employees\");
               return;
           }
           employees[currentEmployees] = employee;
           currentEmployees++;
           break;
       }
       case 2: {
           SalaryEmployee employee = new SalaryEmployee(firstName, lastName,
                   middleInitial, gender, employeeNum, fulltime, wage);
           for (int i = 0; i < employees.length; i++) {
               if (employees[i].getEmployeeNumber() == employeeNum) {
                   System.out.println(\"Duplicate Not Added\");
                   return;

               }
           }
           if (currentEmployees == employeeMax) {
               System.out.println(\"Cannot add more Employees\");
               return;
           }
           employees[currentEmployees] = employee;
           currentEmployees++;
           break;
       }
       case 3: {
           CommissionEmployee employee = new CommissionEmployee(firstName,
                   lastName, middleInitial, gender, employeeNum, fulltime,
                   wage);
           for (int i = 0; i < employees.length; i++) {
               if (employees[i].getEmployeeNumber() == employeeNum) {
                   System.out.println(\"Duplicate Not Added\");
                   return;

               }
           }
           if (currentEmployees == employeeMax) {
               System.out.println(\"Cannot add more Employees\");
               return;
           }
           employees[currentEmployees] = employee;
           currentEmployees++;
           break;
       }
       default:
           System.out.println(\"Invalid Employee Type, None Added\");
           break;
       }

   }

   // Removes an Employee located at the given index from the Employee array.
   public void removeEmployee(int index) {
       employees[index] = null;

   }

   // Lists all the current Employees. Outputs there are none if there are
   // none.
   public void listAll() {
       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null)
                   System.out.println(employees[i].toString());
           }
       }

   }

   // Lists all the current HourlyEmployees. Outputs there are none if there
   // are none.
   public void listHourly() {

       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null) {
                   if (employees[i] instanceof HourlyEmployee)
                       System.out.println(employees[i].toString());
               }
           }
       }
   }

   // Lists all the current SalaryEmployees. Outputs there are none if there
   // are none.
   public void listSalary() {
       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null) {
                   if (employees[i] instanceof SalaryEmployee)
                       System.out.println(employees[i].toString());
               }
           }
       }
   }

   // Lists all the current CommissionEmployees. Outputs there are none if
   // there are none.
   public void listCommission() {
       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null) {
                   if (employees[i] instanceof CommissionEmployee)
                       System.out.println(employees[i].toString());
               }
           }
       }
   }

   public void resetWeek() {
       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               employees[i].resetWeek();
           }
       }
   }

   public double calculatePayout() {

       double payOut = 0;
       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               payOut += employees[i].calculateWeeklyPay();
           }
       }

       return payOut;
   }

   public int getIndex(int employeeNum) {

       for (int i = 0; i < employees.length; i++) {
           if (employees[i].getEmployeeNumber() == employeeNum) {

               return i;

           }
       }
       return -1;
   }

   public void annualRaises() {

       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               employees[i].annualRaise();
           }
       }
   }

   public double holidayBonuses() {
       double holiBonus = 0;
       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               holiBonus += employees[i].holidayBonus();
           }
       }

       return holiBonus;
   }

   // Increase the hours worked of the Employee at the given index by the given
   // double amount.
   public void increaseHours(int index, double amount) {

       if (employees[index] != null
               && employees[index] instanceof HourlyEmployee) {
           HourlyEmployee employee = (HourlyEmployee) employees[index];
           employee.increaseHours(amount);
       }
   }

   // Increase the sales of the Employee at the given index by the given double
   // amount.
   public void increaseSales(int index, double amount) {

       if (employees[index] != null
               && employees[index] instanceof CommissionEmployee) {
           CommissionEmployee employee = (CommissionEmployee) employees[index];
           employee.increaseSales(amount);
       }

   }

}

Solution

public void addEmployee(int input, String firstName, String lastName,
           char middleInitial, char gender, int employeeNum, boolean fulltime,
           double wage) {

       switch (input) {
       case 1: {
           HourlyEmployee employee = new HourlyEmployee(firstName, lastName,
                   middleInitial, gender, employeeNum, fulltime, wage);
           for (int i = 0; i < employees.length; i++) {
               if (employees[i].getEmployeeNumber() == employeeNum) {
                   System.out.println(\"Duplicate Not Added\");
                   return;

               }
           }
           if (currentEmployees == employeeMax) {
               System.out.println(\"Cannot add more Employees\");
               return;
           }
           employees[currentEmployees] = employee;
           currentEmployees++;
           break;
       }
       case 2: {
           SalaryEmployee employee = new SalaryEmployee(firstName, lastName,
                   middleInitial, gender, employeeNum, fulltime, wage);
           for (int i = 0; i < employees.length; i++) {
               if (employees[i].getEmployeeNumber() == employeeNum) {
                   System.out.println(\"Duplicate Not Added\");
                   return;

               }
           }
           if (currentEmployees == employeeMax) {
               System.out.println(\"Cannot add more Employees\");
               return;
           }
           employees[currentEmployees] = employee;
           currentEmployees++;
           break;
       }
       case 3: {
           CommissionEmployee employee = new CommissionEmployee(firstName,
                   lastName, middleInitial, gender, employeeNum, fulltime,
                   wage);
           for (int i = 0; i < employees.length; i++) {
               if (employees[i].getEmployeeNumber() == employeeNum) {
                   System.out.println(\"Duplicate Not Added\");
                   return;

               }
           }
           if (currentEmployees == employeeMax) {
               System.out.println(\"Cannot add more Employees\");
               return;
           }
           employees[currentEmployees] = employee;
           currentEmployees++;
           break;
       }
       default:
           System.out.println(\"Invalid Employee Type, None Added\");
           break;
       }

   }

   // Removes an Employee located at the given index from the Employee array.
   public void removeEmployee(int index) {
       employees[index] = null;

   }

   // Lists all the current Employees. Outputs there are none if there are
   // none.
   public void listAll() {
       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null)
                   System.out.println(employees[i].toString());
           }
       }

   }

   // Lists all the current HourlyEmployees. Outputs there are none if there
   // are none.
   public void listHourly() {

       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null) {
                   if (employees[i] instanceof HourlyEmployee)
                       System.out.println(employees[i].toString());
               }
           }
       }
   }

   // Lists all the current SalaryEmployees. Outputs there are none if there
   // are none.
   public void listSalary() {
       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null) {
                   if (employees[i] instanceof SalaryEmployee)
                       System.out.println(employees[i].toString());
               }
           }
       }
   }

   // Lists all the current CommissionEmployees. Outputs there are none if
   // there are none.
   public void listCommission() {
       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null) {
                   if (employees[i] instanceof CommissionEmployee)
                       System.out.println(employees[i].toString());
               }
           }
       }
   }

   public void resetWeek() {
       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               employees[i].resetWeek();
           }
       }
   }

   public double calculatePayout() {

       double payOut = 0;
       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               payOut += employees[i].calculateWeeklyPay();
           }
       }

       return payOut;
   }

   public int getIndex(int employeeNum) {

       for (int i = 0; i < employees.length; i++) {
           if (employees[i].getEmployeeNumber() == employeeNum) {

               return i;

           }
       }
       return -1;
   }

   public void annualRaises() {

       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               employees[i].annualRaise();
           }
       }
   }

   public double holidayBonuses() {
       double holiBonus = 0;
       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               holiBonus += employees[i].holidayBonus();
           }
       }

       return holiBonus;
   }

   // Increase the hours worked of the Employee at the given index by the given
   // double amount.
   public void increaseHours(int index, double amount) {

       if (employees[index] != null
               && employees[index] instanceof HourlyEmployee) {
           HourlyEmployee employee = (HourlyEmployee) employees[index];
           employee.increaseHours(amount);
       }
   }

   // Increase the sales of the Employee at the given index by the given double
   // amount.
   public void increaseSales(int index, double amount) {

       if (employees[index] != null
               && employees[index] instanceof CommissionEmployee) {
           CommissionEmployee employee = (CommissionEmployee) employees[index];
           employee.increaseSales(amount);
       }

   }

}

Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions. EmployeeManager EmployeeMan
Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions. EmployeeManager EmployeeMan
Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions. EmployeeManager EmployeeMan
Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions. EmployeeManager EmployeeMan
Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions. EmployeeManager EmployeeMan
Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions. EmployeeManager EmployeeMan
Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions. EmployeeManager EmployeeMan
Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions. EmployeeManager EmployeeMan
Programming just give the best example you can on this program doesn\'t have to be right. Just close as you think to the directions. EmployeeManager EmployeeMan

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site