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

  Research report on software design

Write a Research Report on software design and answer diffrent type of questions related to design. Report contain diffrent basic questions related to software design.

  A case study in c to java conversion and extensibility

A Case Study in C to Java Conversion and Extensibility

  Create a structural model

Structural modeling is a different view of the same system that you analyzed from a functional perspective. This model shows how data is organized within the system.

  Write an report on a significant software security

Write an report on a significant software security

  Development of a small software system

Analysis, design and development of a small software system.

  Systems analysis and design requirements

Systems Analysis and Design requirements

  Create a complete limited entry decision table

Create a complete limited entry decision table

  Explain flow boundaries map

Explain flow boundaries map the dfd into a software architecture using transform mapping.

  Frame diagrams

Prepare a frame diagram for the software systems.

  Identified systems and elements of the sap system

Identify computing devices, which could be used to support Your Improved Process

  Design a wireframe prototype

Design a wireframe prototype to meet the needs of the personas and requirements.

  Explain the characteristics of visual studio 2005

Explain the characteristics of Visual Studio 2005.

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