SlideShare a Scribd company logo
CIS247 iLab 6 Abstract Classes


Click this link to get the tutorial:
http://homeworkfox.com/tutorials/general-
questions/4465/cis247-ilab-6-abstract-classes/

Week 6: Interfaces and Abstract Classes - iLab

                                                                                                Print This



                                                                                                    Page



iLab 6 of 7: Abstract Class and Polymorphism



                                        Connect to the iLab here.


        Submit your assignment to the Dropbox located on the silver tab at the
        top of this page.

        (See Syllabus "Due Dates for Assignments & Exams" for due dates.)




 iLAB OVERVIEW
Scenario and Summary

We have two separate goals this week:

   1. We are going to create an abstract Employee class and two pure virtual functions - calculatePay()
      and displayEmployee(). The abstract Employee class will prevent a programmer from creating an
      object based on Employee, however, a pointer can still be created. Objects based on Salaried
      and Hourly will be allowed. The pure virtual function calculatePay() in Employee will force the
      child classes to implement calculatePay(). The other pure virtual function displayEmployee() in
      Employee will force the child classes to implement displayEmployee().
   2. We are going to implement Polymorphism and dynamic binding in this iLab.

Deliverables
Due this week:

     •    Capture the Console output window and paste it into a Word document.
     •    Zip the project folder in the Microsoft Visual Studio.

     •    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 a pure
virtual function and needs to be implemented in the derived classes. In addition, make displayEmployee()
method a pure virtual function as well.




Employee #firstName : string #lastName : string #gender : char #dependents : int #annualSalary : double #benefit : Benefit
-static numEmployees : int = 0 +Employee() +Employee(in fname : string, in lname : string, in gen : char, in dep : int, in
benefits : Benefit) +static getNumEmployees() : int +CalculatePay() : double +displayEmployee() : void Benefit
-healthinsurance : string -lifeinsurance : double -vacation : int +Benefit() +Benefit(in hins : string, in lins : double, in vac : int)
+displayBenefits() : void Salaried -MIN_MANAGEMENT_LEVEL : int = 0 -MAX_MANAGEMENT_LEVEL : int = 3
-BONUS_PERCENT : double = 10 -managementLevel : int +Salaried() +Salaried(in fname : string, in lname : string, in gen :
char, in dep : int, in sal : double, in ben : Benefit, in manLevel : int) +Salaried(in sal : double, in manLevel : int)
+CalculatePay() : double +displayEmployee() : void Hourly -MIN_WAGE : double = 10 -MAX_WAGE : double = 75
-MIN_HOURS : double = 0 -MAX_HOURS: double = 50 -wage : double -hours : double -category : string +Hourly()
+Hourly(in wage : double, in hours : double, in category : string) +Hourly(in fname : string, in lname : string, in gen : char, in
dep : int, in wage : double, in hours : double, in ben : Benefit, in category : string) +CalculatePay() : double
+displayEmployee() : void
STEP 2: Create the Project

Create a new project and name it CIS247C_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
   1. Define calculatePay() as a pure virtual function.
   2. Define displayEmployee() as a pure virtual function.

     3. When class Employee contains two pure virtual functions, it becomes an abstract class.


STEP 4: Create Generalized Input Methods

Reuse method getInput() from the previous iLab to prompt the user to enter Employee information.


STEP 5: Modify the Main Method

Create two employee pointers with:
Employee *employeeList1 = new Salaried(10000,3); Employee *employeeList2 = new Hourly(50, 40, "full time");

The first employee pointer refers to a salaried employee and the second employee pointer refers to a
hourly employee.

Prompt the user to enter information for these two pointers and display the calculated result.

For salaried employee, the following information needs to be displayed:

                                              Partial Sample Output:




Screenshot of program output that reads: Employee Information ________________________________________ Name:
Nana Liu Gender: F Annual Salary: 60000.00 Weekly Salary: 1500.00 Benefit Information
________________________________________ Health Insurance: PPO Life Insurance: 1.50 Vacation: 21 days Salaried
Employee Management level: 3

For hourly employee, the following information needs to be displayed:

                                              Partial Sample Output:




Screenshot of program output that reads: Name: Jackie Chan Gender: M Dependents: 1 Annual Salary: 100000.00 Weekly
Salary: 2000.00 Benefit Information ________________________________________ Health Insurance: HMO Life
Insurance: 100.00 Vacation: 18 days Hourly Employee Category: full time Wage: 50.00 Hours: 40.00
STEP 6: Compile and Test

When done, compile and run your code.

Then, 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.

Below is a complete sample program output for your reference.




Screenshot of program output that reads: Welcome to your Object Oriented Program--Employee ClassCIS247C, Week 6
LabName: Prof.Nana Liu ************** Employee 1 ************** Please enter your First Name :Nana Please enter your Last
Name :Liu Please enter your Gender :Female Please enter your Dependents :2 Please enter your Annual Salary :60000
Please enter your HealthInsurance:PPO Please enter your LifeInsurance:1.5 Please enter your Vacation Days:21 Employee
Information ________________________________________ Name: Nana Liu Gender: F Dependents: 2 Annual Salary:
60000.00 Weekly Salary: 1500.00 Benefit Information ________________________________________ Health Insurance:
PPO Life Insurance: 1.50 Vacation: 21 days Salaried Employee Management level: 3 ************** Employee 2 **************
Please enter your First Name :Jackie Please enter your Last Name :Chan Please enter your Gender :Male Please enter
your Dependents :1 Please enter your HealthInsurance:HMO Please enter your LifeInsurance:100 Please enter your
Vacation Days:18 Employee Information ________________________________________ Name: Jackie Chan Gender: M
Dependents: 1 Annual Salary: 100000.00 Weekly Salary: 2000.00 Benefit Information
________________________________________ Health Insurance: HMO Life Insurance: 100.00 Vacation: 18 days
Category: full time Wage: 50.00 Hours: 40.00 --- Number of Employee Object Created --- Number of employees: 2 The end
of the CIS247C Week6 iLab. Press any key to continue...
STEP 7: Submit Deliverables

Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to
use the Dropbox, read these Step-by-Step Instructions or watch this          Dropbox Tutorial.



See Syllabus "Due Dates for Assignments & Exams" for due date information.

More Related Content

DOC
Cis247 i lab 6 abstract classes
DOC
Cis247 a ilab 4 composition and class interfaces
DOC
Cis247 a ilab 5 inheritance
DOCX
CIS 247C iLab 4 of 7: Composition and Class Interfaces
KEY
Science powerpoint adreanna thompson paschetto
DOC
Cis247 i lab 7 of 7 putting it all together
DOC
Cis247 i lab 3 overloaded methods and static methods variables
PPTX
Musica
Cis247 i lab 6 abstract classes
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 5 inheritance
CIS 247C iLab 4 of 7: Composition and Class Interfaces
Science powerpoint adreanna thompson paschetto
Cis247 i lab 7 of 7 putting it all together
Cis247 i lab 3 overloaded methods and static methods variables
Musica

Viewers also liked (12)

PPSX
FSW 1 Year Anniversary
DOCX
Cis247 i lab 1 of 7 creating a user interface
PPTX
PPTX
Seminar 2013-6-3
DOC
Cis247 i lab 4 composition and class interfaces
PPT
Poduzetništvo,neizvjesnost i rizik petar kontić
PPTX
Presentazione #ggdticino1
DOC
Cis247 i lab 2 of 7 employee class
DOC
Cis247 i lab 5 inheritance
DOC
Cis247 i lab 1 of 7 creating a user interface
DOCX
Cis247 i lab 2 of 7 employee class
PDF
Meta programing ruby monday
FSW 1 Year Anniversary
Cis247 i lab 1 of 7 creating a user interface
Seminar 2013-6-3
Cis247 i lab 4 composition and class interfaces
Poduzetništvo,neizvjesnost i rizik petar kontić
Presentazione #ggdticino1
Cis247 i lab 2 of 7 employee class
Cis247 i lab 5 inheritance
Cis247 i lab 1 of 7 creating a user interface
Cis247 i lab 2 of 7 employee class
Meta programing ruby monday
Ad

Similar to Cis247 i lab 6 abstract classes (20)

DOC
Cis247 a ilab 5 inheritance
DOC
Cis247 a ilab 4 composition and class interfaces
DOC
Cis247 a ilab 4 composition and class interfaces
DOC
Cis247 a ilab 2 of 7 employee class
DOC
Cis247 a ilab 2 of 7 employee class
DOC
Cis247 a ilab 3 overloaded methods and static methods variables
DOC
Cis 247 all i labs
DOC
Cis247 a ilab 3 overloaded methods and static methods variables
DOCX
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
DOCX
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
DOCX
Assignment Instructions 2_7aExplain the interrelationships bet.docx
PDF
3 Data scientist associate - Case GoalZone - Fitness class attendance study.pdf
DOC
Cmgt 410 cmgt410 cmgt 410 education for service uopstudy.com
PDF
Asp net-mvc-3 tier
DOCX
need help completing week 6 ilab.. i will upload what I currently ha.docx
PDF
Minimum viable product_to_deliver_business_value_v0.4
DOCX
Please be advised that there are four (4) programs just like this on.docx
DOCX
80067787-College-Management-System document
DOCX
Cis 407 i lab 6 of 7
PDF
Lab 2: Creating views at the project level in the web client
Cis247 a ilab 5 inheritance
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee class
Cis247 a ilab 3 overloaded methods and static methods variables
Cis 247 all i labs
Cis247 a ilab 3 overloaded methods and static methods variables
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docx
3 Data scientist associate - Case GoalZone - Fitness class attendance study.pdf
Cmgt 410 cmgt410 cmgt 410 education for service uopstudy.com
Asp net-mvc-3 tier
need help completing week 6 ilab.. i will upload what I currently ha.docx
Minimum viable product_to_deliver_business_value_v0.4
Please be advised that there are four (4) programs just like this on.docx
80067787-College-Management-System document
Cis 407 i lab 6 of 7
Lab 2: Creating views at the project level in the web client
Ad

Cis247 i lab 6 abstract classes

  • 1. CIS247 iLab 6 Abstract Classes Click this link to get the tutorial: http://homeworkfox.com/tutorials/general- questions/4465/cis247-ilab-6-abstract-classes/ Week 6: Interfaces and Abstract Classes - iLab Print This Page iLab 6 of 7: Abstract Class and Polymorphism Connect to the iLab here. Submit your assignment to the Dropbox located on the silver tab at the top of this page. (See Syllabus "Due Dates for Assignments & Exams" for due dates.) iLAB OVERVIEW Scenario and Summary We have two separate goals this week: 1. We are going to create an abstract Employee class and two pure virtual functions - calculatePay() and displayEmployee(). The abstract Employee class will prevent a programmer from creating an object based on Employee, however, a pointer can still be created. Objects based on Salaried and Hourly will be allowed. The pure virtual function calculatePay() in Employee will force the child classes to implement calculatePay(). The other pure virtual function displayEmployee() in Employee will force the child classes to implement displayEmployee(). 2. We are going to implement Polymorphism and dynamic binding in this iLab. Deliverables
  • 2. Due this week: • Capture the Console output window and paste it into a Word document. • Zip the project folder in the Microsoft Visual Studio. • 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 a pure virtual function and needs to be implemented in the derived classes. In addition, make displayEmployee() method a pure virtual function as well. Employee #firstName : string #lastName : string #gender : char #dependents : int #annualSalary : double #benefit : Benefit -static numEmployees : int = 0 +Employee() +Employee(in fname : string, in lname : string, in gen : char, in dep : int, in benefits : Benefit) +static getNumEmployees() : int +CalculatePay() : double +displayEmployee() : void Benefit -healthinsurance : string -lifeinsurance : double -vacation : int +Benefit() +Benefit(in hins : string, in lins : double, in vac : int) +displayBenefits() : void Salaried -MIN_MANAGEMENT_LEVEL : int = 0 -MAX_MANAGEMENT_LEVEL : int = 3 -BONUS_PERCENT : double = 10 -managementLevel : int +Salaried() +Salaried(in fname : string, in lname : string, in gen : char, in dep : int, in sal : double, in ben : Benefit, in manLevel : int) +Salaried(in sal : double, in manLevel : int) +CalculatePay() : double +displayEmployee() : void Hourly -MIN_WAGE : double = 10 -MAX_WAGE : double = 75 -MIN_HOURS : double = 0 -MAX_HOURS: double = 50 -wage : double -hours : double -category : string +Hourly() +Hourly(in wage : double, in hours : double, in category : string) +Hourly(in fname : string, in lname : string, in gen : char, in dep : int, in wage : double, in hours : double, in ben : Benefit, in category : string) +CalculatePay() : double +displayEmployee() : void STEP 2: Create the Project Create a new project and name it CIS247C_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 1. Define calculatePay() as a pure virtual function. 2. Define displayEmployee() as a pure virtual function. 3. When class Employee contains two pure virtual functions, it becomes an abstract class. STEP 4: Create Generalized Input Methods Reuse method getInput() from the previous iLab to prompt the user to enter Employee information. STEP 5: Modify the Main Method Create two employee pointers with:
  • 3. Employee *employeeList1 = new Salaried(10000,3); Employee *employeeList2 = new Hourly(50, 40, "full time"); The first employee pointer refers to a salaried employee and the second employee pointer refers to a hourly employee. Prompt the user to enter information for these two pointers and display the calculated result. For salaried employee, the following information needs to be displayed: Partial Sample Output: Screenshot of program output that reads: Employee Information ________________________________________ Name: Nana Liu Gender: F Annual Salary: 60000.00 Weekly Salary: 1500.00 Benefit Information ________________________________________ Health Insurance: PPO Life Insurance: 1.50 Vacation: 21 days Salaried Employee Management level: 3 For hourly employee, the following information needs to be displayed: Partial Sample Output: Screenshot of program output that reads: Name: Jackie Chan Gender: M Dependents: 1 Annual Salary: 100000.00 Weekly Salary: 2000.00 Benefit Information ________________________________________ Health Insurance: HMO Life Insurance: 100.00 Vacation: 18 days Hourly Employee Category: full time Wage: 50.00 Hours: 40.00 STEP 6: Compile and Test When done, compile and run your code. Then, 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. Below is a complete sample program output for your reference. Screenshot of program output that reads: Welcome to your Object Oriented Program--Employee ClassCIS247C, Week 6 LabName: Prof.Nana Liu ************** Employee 1 ************** Please enter your First Name :Nana Please enter your Last Name :Liu Please enter your Gender :Female Please enter your Dependents :2 Please enter your Annual Salary :60000 Please enter your HealthInsurance:PPO Please enter your LifeInsurance:1.5 Please enter your Vacation Days:21 Employee Information ________________________________________ Name: Nana Liu Gender: F Dependents: 2 Annual Salary: 60000.00 Weekly Salary: 1500.00 Benefit Information ________________________________________ Health Insurance: PPO Life Insurance: 1.50 Vacation: 21 days Salaried Employee Management level: 3 ************** Employee 2 ************** Please enter your First Name :Jackie Please enter your Last Name :Chan Please enter your Gender :Male Please enter your Dependents :1 Please enter your HealthInsurance:HMO Please enter your LifeInsurance:100 Please enter your
  • 4. Vacation Days:18 Employee Information ________________________________________ Name: Jackie Chan Gender: M Dependents: 1 Annual Salary: 100000.00 Weekly Salary: 2000.00 Benefit Information ________________________________________ Health Insurance: HMO Life Insurance: 100.00 Vacation: 18 days Category: full time Wage: 50.00 Hours: 40.00 --- Number of Employee Object Created --- Number of employees: 2 The end of the CIS247C Week6 iLab. Press any key to continue... STEP 7: Submit Deliverables Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these Step-by-Step Instructions or watch this Dropbox Tutorial. See Syllabus "Due Dates for Assignments & Exams" for due date information.