Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Software Engineering Expert

Lab

We have two separate goals this week:

We are going to create an abstract Employee class and an abstract calculatePay method. The abstract Employee class will prevent a programmer from creating an object based on Employee. Only objects based on Salaried and Hourly will be allowed. The abstract calculatePay method in Employee will force the child classes to implement calculatePay.

We are going to implement Polymorphism and dynamic binding by creating generalized methods that accept generalized Employee objects to collect input and display information. However, in the main method we will pass derived objects of the Employee class into the methods.

Deliverables

Capture the console output window and paste it into a Word document.

Zip the project files.

Put the zip file and screenshots (Word document) in the Dropbox.

iLAB STEPS

STEP 1: Understand the UML Diagram

Notice in the updated UML diagram that the Employee class is designated as abstract by having the class name Employee italicized. Also, the calculatePay method is italicized, which means that it is an abstract method and needs to be implemented in the derived classes.

STEP 2: Create the Project

Create a new project and name it CIS247B_WK6_Lab_LASTNAME. Copy all the source files from the Week 5 project into the Week 6 project.
Before you move on to the next step, build and execute the Week 6 project.

STEP 3: Modify the Employee Class

Make the Employee class abstract.
Define calculatePay as an abstract method.

STEP 4: Modify the Hourly Class

Implement the calculatePay method. Since calculatePay is not declared as an abstract method in Employee, all subclasses of Employee must provide an implementation for calculatePay. Unlike the Salaried class, the Hourly class does not currently have an implementation for calculatePay and this will cause an error!

STEP 5: Modify the Main Class - Create Generalized Input Methods

In your Main class, create a method called collectEmployeeInformation that accepts as an argument an Employee object and prompts the user for all the employee attributes, retrieves the attributes, makes any necessary conversions, and then sets the attribute value in the object. Remember you may pass both Salaried and Hourly objects into this method. Therefore it will be necessary to determine which type of object you are deal with, at runtime, using the getClass method. The following is an example of how you might use the getClass method:

Once you have determined the type of object you are dealing with, you will also need to cast that object to the correct type in order to access its class-specific methods. In order to cast a general Employee object to a Salaried object and access one of its class-specific methods, you would do the following:

((Salaried)employee).methodInSalariedClass;

We are also going to implement error handing this week using a try/catch block. Specifically, you should wrap the code used to acquire and set the life insurance amount and vacation days in try-catch blocks as shown below. The "try" portion of the code looks for an error. If an error occurs parsing the integer, it jumps down to the "catch" portion of the code and displays the error message. Because badInput is still true, it loops back to the "do" and starts over. Once the integer is parsed correctly, badInput is set to false so it exits the loop and correctly sets the value for vacation.

STEP 6: Modify the Main Class - Create a Generalized Output Method

Back to Top

Create a method called displayEmployeeInformation that accepts an Employee object, provides an output header string, and then displays Employee information.

STEP 7: Modify the Main Class - Create a Display Number Employee Method

Back to Top

Create a method called displayNumberOfEmployees to display the number of employee objects.

STEP 8: Modify the Main Method

Back to Top

Create an array of employee objects with: Employee employeeList[] = new Employee[2];

For the first employeeList index, create a Salaried employee.

Call the collectEmployeeInformation method, passing in the Salaried object.

Use the displayEmployeeInformation method to display the object's state.

Use the displayNumberEmployees method to display the total number of Employees created. Remember, this includes both Salaried and Hourly employees.

For the second employeeList index, create an Hourly employee.

Repeat Steps 3-5 for the Hourly object.

As an educational exercise, you can try to create an Employee object to verify that an error will occur.

STEP 9: Compile and Test

Back to Top

When done, compile and execute your code, and debug any errors until your code is error-free.

Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.

All of the output values should match last week's output.

Software Engineering, Computer Science

  • Category:- Software Engineering
  • Reference No.:- M92020953
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Software Engineering

Assignment part 1objectives to learn to identify the

Assignment Part 1 Objectives: To learn to identify the relevant use cases for a given application, describe the use cases and develop an object-oriented domain model. Problem Statement - Standing Orders Management System ...

Address the following integrating biblical perspectives

Address the following, integrating biblical perspectives where appropriate: Define a hate crime and describe how white supremacist groups use the Internet to spread their message of hate. Explain why hate crime legislati ...

Proposaldesign of an efficient gps tracking system tag for

Proposal Design of an efficient GPS Tracking System (tag) for monitoring small species IMPLEMENTING EMBEDDED SYSTEMS USING SYSML Task Using PapyrusSysML Software (Downloadable online - Evaluation Copy- Latest Version) Mo ...

Instructions - onion routingin this assignment you will

INSTRUCTIONS - ONION ROUTING In this assignment, you will answer the following questions related to Onion Routing and Tor. 1. Describe the infrastructure of Onion Routing and explain how it works for providing anonymity ...

Assignment lab - statement of workclient liberty vacation

Assignment Lab - Statement of Work Client: Liberty Vacation Planning Inc. (LVP) Project: Website Assessment 1. Project Objectives With this statement of work, LVP is engaging you to conduct a website assessment to determ ...

Write review on this article with apa formatgovernment

Write review on this article with APA format. Government surveillance is a major issue in the United States and globally. Surveillance refers to any collection and processing of personal data, whether, identifiable or no ...

Reply to this article with apa referencehate crimes

Reply to this article with APA reference. Hate crimes According to Merriam-Webster, hate crime is any of various crimes (such as assault or defacement of property) when motivated by hostility to the victim as a member of ...

In this assignment you will answer the following questions

In this assignment, you will answer the following questions related to Android platform and Android security design. 1. Describe Android architecture in detail by explaining the four conceptual layers. 2. Describe Androi ...

Research projectin the course we have covered various

RESEARCH PROJECT In the course, we have covered various security and privacy issues that arise in the cyberspace field. We have learned to identify these risks and have discussed the current approaches and developments f ...

In this assignment you will answer the following review

In this assignment, you will answer the following review questions from the reading materials of the module/week. 1. "What are the key components of a typical P2P application? Describe their functions." 2. "What are the ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As