Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview: In Unit 10, you took an object-oriented approach towards creating employee classes that help the Human Resources (HR) department manage vacations and terminations for

Overview:

In Unit 10, you took an object-oriented approach towards creating employee classes that help the Human Resources (HR) department manage vacations and terminations for your growing employee workforce

Unit 10 code:

class Date { // properties private int day; private int month; private int year;

// default constructor public Date() { month = 0; day = 0; year = 0; }

// parameterized constructor public Date(int Day, int Month, int Year) { day = Day; month = Month; year = Year; }

// for displaying public String getDate() { return day + "/" + month + "/" + year; } // update the date public void setDate(int Day, int Month, int Year) { day = Day; month = Month; year = Year; }

}

class Employee { // properties private String firstName; private String lastName; private String fullName; private Date dateOfHire; private Date terminationDate; private int unscheduledDays; private int scheduledDays; private String lastAnnualReview;

// default constructor public Employee() { firstName = ""; lastName = ""; fullName= firstName + " " + lastName; unscheduledDays = 0; scheduledDays = 0; lastAnnualReview = ""; dateOfHire = new Date(); terminationDate = new Date(); }

// parameterized constructor public Employee(String firstName, String lastName, int dd, int mm, int yy) {

this.firstName = firstName; this.lastName = lastName; this.fullName = firstName + " " + lastName; this.unscheduledDays = 0; this.scheduledDays = 0; this.lastAnnualReview = "";

dateOfHire = new Date(); dateOfHire.setDate(dd, mm, yy); terminationDate = new Date(); }

// getter methods

public String getFirstName() { return firstName; }

public String getLastName() { return lastName; }

public String getFullName() { return fullName; }

public Date getDateOfHire() { return dateOfHire; }

public Date getTerminationDate() { return terminationDate; }

public int getUnscheduledDays() { return unscheduledDays; }

public int getScheduledDays() { return scheduledDays; }

public String getLastAnnualReview() { return lastAnnualReview; }

// setter methods public void setFirstName(String firstName) { this.firstName = firstName; }

public void setLastName(String lastName) { this.lastName = lastName; }

public void setFullName(String fullName) { this.fullName = fullName; }

public void setDateOfHire(int dd, int mm, int yy) { this.dateOfHire.setDate(dd, mm, yy); }

public void setTerminationDate(int dd, int mm, int yy) { this.terminationDate.setDate(dd, mm, yy); }

public void setUnscheduledDays(int unscheduledDays) { this.unscheduledDays = unscheduledDays; }

public void setScheduledDays(int scheduledDays) { this.scheduledDays = scheduledDays; }

public void setLastAnnualReview(String lastAnnualReview) { this.lastAnnualReview = lastAnnualReview; } // other methods public void scheduleVacationDay() { if(unscheduledDays > 0) unscheduledDays--; // lose a day from what they have left scheduledDays++; // gain a day to the number they have scheduled } public void cancelVacationDay() { unscheduledDays++; // gain a day from what they have left if(scheduledDays > 0) scheduledDays--; // lose a day to the number they have scheduled } public void terminateEmployee(int dd, int mm, int yy) {

terminationDate.setDate(dd, mm, yy); // get a termination date value }

public String toString() { return " Names: " + fullName + " Date of hire: " + dateOfHire.getDate() + " Termination date: " + terminationDate.getDate() + " unscheduledDays: " + unscheduledDays + " scheduledDays: " + scheduledDays + " lastAnnualReview: " + lastAnnualReview; } }

public class Assignment10 { public static void main(String[] args) {

/* create 3 employees */ Employee employee1 = new Employee("Ale", "Wick", 25, 3, 2020); Employee employee2 = new Employee("Roberto", "Wick", 4, 12, 2019); Employee employee3 = new Employee("John", "Wick", 15, 6, 2021);

/* schedule at least 2 vacation days for each of the 3 employees */

// 3 days employee1.scheduleVacationDay(); employee1.scheduleVacationDay(); employee1.scheduleVacationDay(); // 2 days

employee2.scheduleVacationDay(); employee2.scheduleVacationDay();

// 4 days employee3.scheduleVacationDay(); employee3.scheduleVacationDay(); employee3.scheduleVacationDay(); employee3.scheduleVacationDay();

/* cancel at least 1 vacation day for each of the 3 employees */ // 1 day employee1.cancelVacationDay(); // 1 day employee2.cancelVacationDay(); // 2 days employee3.cancelVacationDay(); employee3.cancelVacationDay(); // terminate 1 employee employee2.terminateEmployee(18, 9, 2021); // output all 3 employees at the end System.out.println(employee1); System.out.println(employee2); System.out.println(employee3); } }

In this unit, you will expand upon object-oriented programming (OOP) concepts by completing a series of tasks designed to reinforce your understanding of OOP and class relationships. Your company project may also incorporate wrapper classes and automatic conversions to demonstrate competency with objects and arrays of objects if appropriate to your design.

Specification:

Your company has now begun the process of expanding its workforce in four geographic locations, or branches, and requires a program to organize employee staffing. Doing so will help your companys HR department with managing each branch office and assist in determining whether the company needs to add more staff or move employees between locations.

Your program will expand on your employee program from the last unit, so be sure it is working correctly before beginning this one. Your program will organize employees for each branch location and add a manager for each branch.

Employee class

You can use the employee class you created in Unit 10 and add new functionality to meet these requirements.

In addition to the current attributes, you will need to add

  • A four digit employeeID with setter and getter methods
  • A static class variable to track total active employees

The constructor method(s) for the employee class should also increment the class variable.

The terminate method for an employee should decrement the class variable

An appropriate getter should be coded for the static class variable to return total number of active employees.

Branch class

The Branch class needs to model the following attributes:

  • 4-digit location ID
  • location name
  • branchID - a four-digit code to indicate location
  • address
  • A Manager object representing the supervisor
  • an array of Employee objects representing the team

The Branch class needs to model the following methods:

  • Default and parameterized constructors
  • Getter and setter methods for the attributes
  • addToTeam method that takes in an Employee object and adds it to the Team array
  • removeFromTeam method that removes the Employee object from the Team
  • displayBranchInfo method to display the supervisor and team information, as well as the number of employees on the team

Manager class

The Manager class can be formatted similarly to the Employee class with the following attributes:

  • The managers First name
  • The managers Last name
  • The managers full name
  • A 4-digit branch ID

The Manager class needs to model the following methods:

  • default and parameterized constructors
  • getter and setter methods

Main method:

You may create your initial employees, managers, and locations programmatically or via user input.

  • Manager objects should be constructed with a default branchID of 9999
  • Branches should have supervisor and team attributes created but not initialized with values

You will write a menu system that has two main functional areas:

Administration:

Select/enter a branch ID, retrieve the corresponding Branch object and offer these options:

  • Assign a manager to supervise the branch
  • Assign an employee to the branch team
  • Remove an employee from the branch team

Reporting:

  • View a report of manager and employees for a specific lcoation
  • View a cumulative report of all employees sorted by branch location, including total managers and total number of employees for the company

The inputs required for testing your program are:

  • Data for three branch locations: 1000 Baltimore, 2000 Boston, and 3000 New York
  • Data for 3-4 employees per branch. Therefore, you will have a total of 9 -12 employees across the 3 branches
  • Data for at least 3 managers

The data constructs, calculations and decisions required are:

  • At least three classes will need to be created.
  • You may re-use and modify your Employee class from Unit 10. Be sure it is working correctly.
  • You must demonstrate the ability to pass an array of Objects.
  • You will need several arrays to hold your objects.
  • When populating the branch team, you will iterate through the employee array and add the objects as selected to the branch team array. Be mindful to set the length correctly when initializing the team array. Intermediate data structures may be used, and passed into the branch team as an array of objects.
  • When assigning a manager to the supervisor attribute in the branch object, be sure to update the branchID for the manager object, too.

The outputs required are:

  • Menu and reports as described above
  • A provision to inform the user of any exceptions (for example, You have entered an invalid branch ID)
  • All other pertinent information, along with a UML diagram PDF, that continues the theme of your course portfolio

Be mindful of testing and debugging procedures, and best practices learned in order to ensure proper output prior to submitting your code. Use comments to describe the purpose of your code revisions and additions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions