I need help with this method in java Just give it your best

I need help with this method in java. Just give it your best shot.

Employee {abstract} implements Comparable<Employee>

- String firstName

- String lastName

- char middleInitial

- boolean fulltime

-   char gender

-   int employeeNum

<<constructor>> Employee (fn : String, ln : String, m : char, g : char, empNum : int, ft : boolean ) throws InvalidEmployeeNumberException

+ getEmployeeNumber() : int

+ setEmployeeNumber(empNum : int) throwsInvalidEmployeeNumberException

+ getFirstName() : String

+ getLastName() : String

+ setFirstName(fn: String)

+ setLastName(ln : String)

+ setMiddleI(m : char)

+ setGender(g : char)

+ equals(e2 : Object) : Boolean

+ toString() : String

+ calculateWeeklyPay() : double {abstract}

+ annualRaise() {abstract}

+ holidayBonus() : double {abstract}

+ resetWeek() {abstract}

+ compareTo(Employee e) : int

setEmployeeNumber(int empNum)

Instead of the setEmployeeNumber reprompting for a valid Employee Number we will use an Exception to inform the calling method it was an invalid Employee number. If an invalid Employee number is passed to the method throw a new InvalidEmployeeNumberException, passing the invalid number to its constructor.

Constructor

The constructor calls upon setEmployeeNumber which now throws the checked Exception of InvalidEmployeeNumber, it should not be caught, rather declared such that the constructor passes the Exception on to the calling method.

public int compareTo(Employee e)

By implementing the Comparable interface, Employee becomes what is known as a Comparable type. All Comparable types have the compareTo() method which determines the logical ordering of instances of the class. This will be based on an Employee’s Employee Number. If the calling Employee’s number is greater than the passed Employee’s number return 1, if it is less than return -1, if they are equal return 0. The use of this will be necessary for the ArrayList’s sort.

Employee {abstract} implements Comparable<Employee>

- String firstName

- String lastName

- char middleInitial

- boolean fulltime

-   char gender

-   int employeeNum

<<constructor>> Employee (fn : String, ln : String, m : char, g : char, empNum : int, ft : boolean ) throws InvalidEmployeeNumberException

+ getEmployeeNumber() : int

+ setEmployeeNumber(empNum : int) throwsInvalidEmployeeNumberException

+ getFirstName() : String

+ getLastName() : String

+ setFirstName(fn: String)

+ setLastName(ln : String)

+ setMiddleI(m : char)

+ setGender(g : char)

+ equals(e2 : Object) : Boolean

+ toString() : String

+ calculateWeeklyPay() : double {abstract}

+ annualRaise() {abstract}

+ holidayBonus() : double {abstract}

+ resetWeek() {abstract}

+ compareTo(Employee e) : int

Solution

Need more information to write below methods

+ calculateWeeklyPay() : double {abstract}

+ annualRaise() {abstract}

+ holidayBonus() : double {abstract}

+ resetWeek() {abstract}

ping me if you need any furthur help

class InvalidEmployeeNumberException extends Exception {

   InvalidEmployeeNumberException(String s) {

       super(s);

   }

}

public class Employee implements Comparable<Employee> {

   String firstName;

   String lastName;

   char middleInitial;

   boolean fulltime;

   char gender;

   int employeeNum;

   public Employee(String firstName, String lastName, char middleInitial, boolean fulltime, char gender,

           int employeeNum) throws InvalidEmployeeNumberException {

       super();

       this.firstName = firstName;

       this.lastName = lastName;

       this.middleInitial = middleInitial;

       this.fulltime = fulltime;

       this.gender = gender;

       this.setEmployeeNum(employeeNum);

   }

   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 char getMiddleInitial() {

       return middleInitial;

   }

   public void setMiddleInitial(char middleInitial) {

       this.middleInitial = middleInitial;

   }

   public boolean isFulltime() {

       return fulltime;

   }

   public void setFulltime(boolean fulltime) {

       this.fulltime = fulltime;

   }

   public char getGender() {

       return gender;

   }

   public void setGender(char gender) {

       this.gender = gender;

   }

   public int getEmployeeNum() {

       return employeeNum;

   }

   public void setEmployeeNum(int employeeNum) throws InvalidEmployeeNumberException {

       if (employeeNum < 0)

           throw new InvalidEmployeeNumberException(\"not valid\");

       this.employeeNum = employeeNum;

   }

   @Override

   public String toString() {

       return \"Employee [firstName=\" + firstName + \", lastName=\" + lastName + \", middleInitial=\" + middleInitial

               + \", fulltime=\" + fulltime + \", gender=\" + gender + \", employeeNum=\" + employeeNum + \"]\";

   }

   @Override

   public int compareTo(Employee o) {

       if (this.employeeNum > o.employeeNum)

           return 1;

       else if (this.employeeNum < o.employeeNum)

           return -1;

       else

           return 0;

   }

   public boolean equals(Employee o) {

       if (this.firstName.equals(o.firstName) && this.lastName.equals(o.lastName)

               && this.middleInitial == o.middleInitial && this.fulltime == o.fulltime && this.gender == o.gender

               && this.employeeNum == o.employeeNum)

           return true;

       else

           return false;

   }

}

I need help with this method in java. Just give it your best shot. Employee {abstract} implements Comparable<Employee> - String firstName - String lastNam
I need help with this method in java. Just give it your best shot. Employee {abstract} implements Comparable<Employee> - String firstName - String lastNam
I need help with this method in java. Just give it your best shot. Employee {abstract} implements Comparable<Employee> - String firstName - String lastNam
I need help with this method in java. Just give it your best shot. Employee {abstract} implements Comparable<Employee> - String firstName - String lastNam
I need help with this method in java. Just give it your best shot. Employee {abstract} implements Comparable<Employee> - String firstName - String lastNam

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site