CREATING A PROGRAM INVOLVING MULTIPLE CLASSES

Qualified Writers
Rated 4.9/5 based on 2480 reviews

100% Plagiarism Free & Custom Written - Tailored to Your Instructions

Overview

While the first assignment focused primarily on declarative programming using control structures, this assignment will require you to demonstrate your object-oriented programming skills by creating a program involving multiple classes. It draws on the material covered in Weeks 1-10 of the course.

The assignment task consists of implementing a tool which would assist the manager of a small company in scheduling employees. The Appendix at the back of this document provides a sample screenshot showing a working solution to the assignment as a guide to how it should function.

Timelines and Expectations

Percentage Value of Task: 20%
Due: 4pm Friday of Week 11 – refer to your course description for the date
Minimum time expectation: 20 hours

Learning Outcomes Assessed

The following course learning outcomes are assessed by completing this assessment:

• K1. identify and use the correct syntax of a common programming language;
• K2. recall and use typical programming constructs to design and implement simple software solutions;
• K3. reproduce and adapt commonly used basic algorithms;
• K4. explain the importance of programming style concepts (documentation, mnemonic names, indentation);
• S1. utilise pseudocode and/or algorithms as a major program design technique;
• S2. write and implement a solution algorithm using basic programming constructs;
• S3. demonstrate debugging and testing skills whilst writing code;
• S4. describe program functionality based on analysis of given program code
• A1. develop self-reliance and judgement in adapting algorithms to diverse contexts;
• A2. design and write program solutions to identified problems using accepted design constructs

Assessment Details

The assignment task consists of implementing a tool which would assist the manager of a small company in scheduling employees. The details of the company’s operations are as follows:

• It operates on 5 days of the week (not on the weekends). On each day the company runs four shifts, and a single employee is required for each shift.
• The company employs both permanent employees and casual employees.
• Permanent employees are allocated to the same shift for all 5 days of a week, and are paid a fixed weekly wage.
• Casual employees can be allocated to any number of shifts per week (including zero), and are paid a fixed amount per shift worked.

The Employee Class

The first stage in this assignment is to define a Java class for an Employee based on the UML diagram on the next page. The methods of Employee should perform as follows:

- The constructor simply initialises the instance variables to the values provided as parameters, and sets shiftsWorkedThisWeek to 0
- The accessor methods (gets) simply return the value of their corresponding variable
- There are no set methods – it is assumed that the employee’s name and ID will not change
- resetShiftsWorkedThisWeek() sets shiftsWorkedThisWeek to 0
- incrementShiftsWorkedThisWeek () adds one on to the current value of shiftsWorkedThisWeek
- calculateWeeklyPay() is provided so that it can be over-ridden by the subclasses – this method can be declared as abstract
- the toString method returns a String describing the Employee
o this should be formatted as their employee ID in square brackets, followed by their last name in all upper-case, a comma, and their first-name in mixed-case
o for example, if we have instantiated an Employee as follows Employee e = new Employee(“Joe”,”Bloggs”,”BLO12345678”); then calling e.toString should return the String “[BLO12345678] BLOGGS, Joe”

You should also write a small driver class called TestEmployee, and thoroughly test the Employee class before proceeding further.

Employee

- String firstName;

- String lastName;

- String ID;

- int shiftsWorkedThisWeek;

~ Employee(firstName:String; lastName:String; ID:String)

+ getFirstName(): String

+ getLastName(): String

+ getID(): String

+ getShiftsWorkedThisWeek()

+ resetShiftsWorkedThisWeek()

+ incrementShiftsWorkedThisWeek()

+ calculateWeeklyPay():double

+ toString():String


The PermanentEmployee and CasualEmployee classes

You will also need to create two subclasses of Employee called PermanentEmployee and CasualEmployee. These will inherit from and extend the Employee class as shown in the following UML diagram (refer to Week 10’s material on inheritance to see how to implement this):

PermanentEmployee (extends Employee)

- weeklyWage: double

~ PermanentEmployee(firstName:String; lastName:String; ID:String)

~ PermanentEmployee(firstName:String; lastName:String; ID:String; weeklyWage: double)

+ setWeeklyWage(weeklyWage: double)

+ getWeeklyWage(): double

+ calculateWeeklyPay():double

CasualEmployee (extends Employee)

- shiftRate: double

~ CasualEmployee(firstName:String; lastName:String; ID:String)

~ CasualEmployee(firstName:String; lastName:String; ID:String; shiftRate: double)

+ setShiftRate(shiftRate: double)

+ getShiftRate(): double

+ calculateWeeklyPay():double

Each of these subclasses should provide two constructors. One takes four parameters, with the last being the weekly wage (for PermanentEmployees) or the per-shift payment rate (for CasualEmployees). The second constructor for each subclass omits this fourth parameter – in this case the payment-related variable should be a set to a default value. For PermanentEmployees the default weekly wage is $812.47, while for CasualEmployees the default payment per shift is $47.50.

Each subclass also needs to provide its own implementation of the getWeeklyWage() method. For the PermanentEmployee class this can just return the employee’s weekly wage, while for the CasualEmployee class it should return the product of the number of shifts worked and the rate of payment per shift.

Once you have implemented these subclasses, you should extend the TestEmployee driver code to instantiate several examples of these classes and call their method to ensure that they are working correctly.

The EmployeeDriverSystem

The final component of the scheduling software system is the EmployeeDriverSystem. This should have a main() method, and will implement a text-driven menu to allow the company manager to work with this week’s schedule.

This driver program will be based on two array data-structures (see Week 7 for coverage of arrays):

• The first is a 1-dimensional array which will store a list of all of the company’s Employees
• The second is a 2-dimensional array which will store the week’s schedule. Each element in this array corresponds to a specific day (the first index) and shift (the second index), and it stores a reference to an Employee object. If an element contains the value null, this indicates that no Employee has been allocated to that specific day and shift yet.

When the program first starts these array data-structures should be created to the required size. The program should instantiate multiple Employees and store them in the employee list array. The employees should have the following characteristics:

• There should be 3 permanent employees and 7 casual employees.
• You should use both the 3 and 4 parameter variants of the constructors for the PermanentEmployee and CasualEmployee classes (i.e. some employees will have the default pay-rates, while others may have higher or lower pay-rates)
• You can make up the names and ID codes for all of the employees, with the exception that the first employee should use your names, and their ID code should consist of the first three letters of your surname followed by the 8 digits of your FedUni student number.
• The data for these Employees can be stored directly in your code.

Once the arrays have been created, the program should display the following text menu to the user. The user should be able to repeatedly select operations from this menu, until they choose to exit the program. You should validate the values entered by the user and print an error message and prompt them to try again if they enter an invalid value:

MENU
1. Display all staff
2. Clear schedule
3. Display schedule
4. Assign shift to casual employee
5. Assign shifts to permanent employee
6. Calculate total weekly wages
7. Exit program
Enter your selection:

The menu commands should operate as follows:

• Display all staff
o Displays a list of all the company employees (the order is not important) – see sample output at the end of this document for the required format

• Clear schedule
o Sets all entries in the schedule to null, and all employees shifts worked to zero

• Display schedule
o Displays the current schedule, with one row per day (labelled with the day’s name or abbreviation) and the 4 shifts displayed in columns. Unallocated shifts should be indicated by dashes. For allocated shifts the details of the allocated employee should be displayed. Refer to the sample output at the end of this document for an example.

• Assign shift to casual employee
o Prompt the user to enter both a day of the week and a shift number (these values should be tested to make sure they are in range, and the user prompted to re-enter them if they are invalid)
o Once a valid day and shift number have been entered, check to see if that shift has already been allocated. If so, then the program should display an appropriate message and return to the menu.
o If the selected shift is not allocated, the program should display a list of all casual employees (permanent employees should not be listed)
Hint: you can use Java’s instanceof operator to check if an Employee is casual or permanent
o The user should be prompted to select an employee by entering their ID as a String
o When the ID is entered, the program should test if it matches the ID of a casual employee
o If it does, that Employee should be allocated to this shift and their shifts worked should beincremented
o If the ID doesn’t match (or if it matches a permanent employee) the program should display an error message and ask the user to enter a new ID – repeat this until a valid ID is entered

• Assign shift to permanent employee
o Prompt the user to enter a shift number (this value should be tested to make sure it is in range, and the user prompted to re-enter it if it is invalid)
o Check to see if this shift is unallocated for all 5 days of the week – if any day already has this shift allocated the program should display an appropriate message and return to the menu.
o If the selected shift number is available on all days, then the program should display a list of all permanent employees (casual employees should not be listed)
Hint: you can use Java’s instanceof operator to check if an Employee is casual or permanent
o The user should be prompted to select an employee by entering their ID as a String
o When the ID is entered, the program should test if it matches the ID of a permanent employee
o If it does, that Employee should be allocated to this shift number for all 5 days and their shifts worked should be incremented by 5
o If the ID doesn’t match (or if it matches a casual employee) the program should display an error message and ask the user to enter a new ID – repeat this until a valid ID is entered

• Calculate total weekly wages
o The program should list the details of all employees along with their calculated pay for this week based on the current schedule (see the printout at the back of this document for an example of the layout required)
o The program should also total the pay across all employees and display this at the bottom of the list

• Exit program
o The program should exit the menu loop, displaying a farewell message to the user.

Important note: While the full version of the system will require you to have implemented the CasualEmployee and PermanentEmployee classes, you can begin implementation of the menu and some of the functionality using just the Employee class. As we will not cover inheritance until Week 10, it is important that you start earlier on the other aspects of the assignment to avoid having to implement too much in the last week.

File handling

If you have all of the other program functionality working, a small number of marks are available for performing the initialisation of the Employee array by loading the data from a text-file. We will not cover file-handling until Week 10, so this should be the last feature which you add to your program.

Testing

You should be testing your program as each stage is completed, and again once the program is complete. As well as your program code, you must submit a document detailing the testing which you have performed on your program. This should be formatted according to the University’s guidelines for academic work. This should detail the input data given to the program, why that particular data was chosen, and the expected and actual output from the program.

Your testing should be thorough. Your mark for this section will reflect the thoroughness of your testing and the quality of your documentation.

Price: £109

100% Plagiarism Free & Custom Written - Tailored to Your Instructions