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

Questions Cloud

Record a liability for pending litigation for threatened lit : What factors must be considered in determining whether or not to record a liability for pending litigation for threatened litigation?
Choice of borrowing from a finance company : Calculating EAR You have a choice of borrowing from a finance company at 23 percent compounded annually or borrowing money from a bank at 25 percent compounded daily. Which alternative is the most attractive.
Describe the conflicting emotions the parent may have : What can a teacher do to reinforce the primary relationship between the parent and the child and to communicate that the teacher does not desire to take the parent's place in the child's life?
Should a liability be recorded for risk of loss : Should a liability be recorded for risk of loss due to lack of insurance coverage? Discuss.
Explain the importance of programming style concepts : The assignment task consists of implementing a tool which would assist the manager of a small company in scheduling employees -  Explain the importance of programming style concepts
Appreciate at an annual rate : Your coin collection contains 49 1952 silver dollars. If you relatives purchased them for their face value when they were new, how much will your collection be worth when you retire in 2047, assuming that they appreciate at an annual rate of 4 pe..
List the services provided and populations served : Describe case management models applied within the case manager's role as a human service worker. Describe his or her role in linking clients to community resources.
Any established company and perform swot analysis : Perform a SWOT analysis of the company you would like to launch OR select any established company and perform a SWOT analysis. Having identified the company's external opportunities and threats and its internal strengths and weaknesses, you need to c..
Present value of winning amount : The prize will be awarded on your 80th birthday, 60 years from now. What is the present value of your winning amount if the appropriate discount rate is 7 percent?

Reviews

Write a Review

JAVA Programming Questions & Answers

  What secret does soraya tell amir

What secret does soraya tell amir and how does amir react to this information

  Adopting a working game of ping pong in java

Create a new Java project. You will be porting each of the classes from the example code to swing, so its better to code in empty class and fill in the details - Object-Oriented Design in Java

  Calculates the cost of a mortgage

Write a class called Mortgage that calculates the cost of a mortgage. Prompt the user to enter the principal amount, the term in years, and the interest rate per year.

  Write an app to test class integerset

Create class IntegerSet. Each IntegerSet object can hold integers in the range 0-100. The set is represented by an array of bools. Array element

  Eliminate the last comma in the string output

Eliminate the last comma in the String Output which includes array output values from "hourlyTemp[i]" (entire list). My guess is that this needs to incorporate "%d" somehow but my online book won't accept the use of "%d" for some reason. From the boo..

  Demonstrate knowledge of design patterns

Your software should make use of the concepts outlined at the start of the assignment brief above. Think about where you can employ appropriate design patterns and other techniques.

  Output the number of tails using the constant array

Assume that this program compiles and runs. Assume that the user enters 5 0 (separated by a space) for input. What is the output. As always, be precise when showing your output. Output the number of Tails using the constant array for the "Tails" h..

  A recently formed committee to deal with numerous

Scenario: You are a member of a recently formed committee to deal with numerous complaints against police and correction officers in your town and are asked to determine if there is merit to these allegations and develop a protocol to address the cur..

  What are the merits and demerits of the use of mainframes

write a 200- to 300-word short-answer response to the followingwhat are the advantages and disadvantages of the use of

  Create an array of size n and fill it

Sketch a high level design of what you want to implement using the UML notation. At the very least, you should have a use case diagram, class diagram and a sequence diagram.

  Return a reverse queue

represent my queue object as a parameter, what the program should be doing. It should return a reverse queue

  Define javascript and servlet

The web site must be built using one of these techniques. JavaScript and servlet

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