Explain the importance of programming style concepts

Assignment Help JAVA Programming
Reference no: EM131115449

Learning Outcomes

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

Identify and use the correct syntax of a common programming language;

Recall and use typical programming constructs to design and implement simple software solutions;

Reproduce and adapt commonly used basic algorithms;

Explain the importance of programming style concepts (documentation, mnemonic names, indentation);

Utilise pseudocode and/or algorithms as a major program design technique;

Write and implement a solution algorithm using basic programming constructs;

Demonstrate debugging and testing skills whilst writing code;

Describe program functionality based on analysis of given program code

Develop self-reliance and judgement in adapting algorithms to diverse contexts;

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

Figure 1: UML Diagram for the class Employee

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

Figure 2: UML Diagram for the class PermanentEmployee

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

Figure 3: UML Diagram for the class CasualEmployee

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 be incremented
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.

Your assignment should be completed according to the General Guidelines for Presentation of Academic Work.
The following criteria will be used when marking your assignment:
- successful completion of the required tasks
- quality of code that adheres to the programming standards for the course including:
- comments and documentation
- code layout
- meaningful variable names
- use of constants

You are required to provide documentation, contained in an appropriate file, which includes:
- a front page - indicating your name, a statement of what has been completed and acknowledgement of the names of all people (including other students and people outside of the university) who have assisted you and details on what parts of the assignment that they have assisted you with
- details of test data and evidence that the testing was conducted
- list of references used (APA style); please specify if none have been used.

Using the link provided in Moodle, please upload the following in one zip file:
1. your code (all of your .java files)
2. your report (surnameStudentIDAssign2.docx)

If you encounter any problems in uploading files to moodle please report this to your lecturer or other staff member as soon as possible.

Attachment:- Assignment speci.rar

Reference no: EM131115449

Build a thread system

Identify all Nachos classes that you will modify and where you plan to do you modifications - Identify all classes that you plan to implement and give the API for each class,

Problem regarding the protocol conformance

We can compare Smalltalk interfaces to classes that use protocols, which are lists of operation names (selectors). When a selector allows parameters, as in at: put: , the se

Implements simulation for movie borrowing and return system

For this assignment you need to write a console application in the Java programming language which implements a simulation for a movie borrowing and return system for the vi

Write a generic class

Write a generic class (using Java generics) called Pair that stores two values of the generic type.  It should have a constructor to set them, two methods getfirst() and get

Review the given code fragment from arraybag class

Review the given code fragment from ArrayBag class below and answer the following: Explain each line in your own words: Write the header (signature) of the method that contain

Create a class named blooddata that includes fields

Create a class named BloodData that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and an Rh factor (the factors are + and -). Create a de

A program that reads a four-digit number from the keyboard

Write a program that reads a four-digit number from the keyboard as a string and then converts it into decimal. For example, if the input is 1100, the output should be 12. Hin

Create your own short and simple jdbc java code

Using the Schema you developed in Homework 1 for your e-Commerce project, design and implement a Virtual Private Database that limits database access. Your design should be

Reviews

Write a Review

 
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd