Create a method called displayemployeeinformation

Assignment Help Software Engineering
Reference no: EM131266200

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.

Reference no: EM131266200

Questions Cloud

Find a new product or system that maintains long-term secret : Find a new product or system that was announced or released within the last three months. Conduct a security review of that product or system as described in Section 1.12. Pick one of the assets that you identified and construct an attack tree for..
Display a welcome message in a message dialog box : Display a welcome message in a Message Dialog Box (JOptionPane.showMessageDialog()) that includes the full name, e.g., "Welcome John Q Smith.".
Discuss an advertising campaign that you feel is successful : Discuss an advertising campaign that you feel was/is successful. - Why do you think it was so successful?- What was the target audience.
Provide information regarding the most common drugs : Express your personal perspective on the nature and complexity of our society's current problems with drug use. Provide information regarding the most common drugs of abuse both in the United States, and more specifically in Florida. Back up your ..
Create a method called displayemployeeinformation : Create a method called displayEmployeeInformation that accepts an Employee object, provides an output header string, and then displays Employee information.
Billions of dollars of fixed investment : Microprocessors for computers are produced in "fabs," large high-tech factories which can require billions of dollars of fixed investment. Do you expect there will be a range of declining average cost in the microchip industry? How does your answe..
Level of consumer and producer surplus : What price do you expect to prevail if the new screening methods are adopted? How many units of blood will be used in the United States? What is the level of consumer and producer surplus? Illustrate your findings in a graph.
Assessing and securing systems on a wide area network : Assessing and securing systems on a wide area network (WAN). Ten pages however , no more than fifteen pages , 12 point front , Times New Roman and doubled spaced. Your name should appear in the header along with page number.
Identify different entities that be involved in developing : Outline the process for developing nursing standards of practice, and identify the different entities that might be involved in developing a standard of practice.

Reviews

Write a Review

Software Engineering Questions & Answers

  Implications of new knowledge gained

The final paper should demonstrate an understanding of the materials in this course, as well as the implications of new knowledge gained. The 3-4-page paper should integrate new learning into the target company example and internship work. It may ..

  A light blue background color

Write the CSS for a class with the following attributes: a light blue background color, Arial or sans-serif font, dark blue text color, 10 pixels of padding, and a narrow dashed border in dark blue color. Here is what I have but it doesn't seem to ap..

  Analyze how projects are planned and execute

Analyze how projects are planned and executed under the following frameworks and provide an example for each: SCRUM and DSDMc. Lean Software Development

  Quality web design company

the Course Project (comprised of Phase I and II) - Recommend solutions to the potential weaknesses from either the Aircraft Solutions or Quality Web Design Company.

  What is cloud computing

Types of Cloud Computing (Private, Public, Hybrid)"

  Types of boundary classes

What makes a good analysis class. The three types of boundary classes are

  Draw flow chart to compute arithmetic operation

While drawing flow chart, you require to add little more functionality as follows like during any computations of any arithmetic operation, if result exceeds 2000 or comes equal to 100, user must input the data again

  Why is it important to have a communication plan

Why is it important to have a communication plan and produce a small version of the communication plan that includes at least two key entries that you would expect for this project.

  1 describe the mix of media you would use to implement your

1. describe the mix of media you would use to implement your public relations campaign and explain in detail your

  Describe your chosen architecture pattern

Describe your chosen architecture pattern. Explain how your chosen pattern could be applied to this case study

  Domain model & state

Domain Model & State-Transition Diagram Problem An airline company would like to manage their planes and flight routes. They have 4 airplanes and they fly to 10 destinations. Planes are either in-flight or at a location (source or destination). Each ..

  Is there a place for ethics in iton march 15 2005 michael

is there a place for ethics in it?on march 15 2005 michael schrage published an article in cio magazine entitled ethics

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