SlideShare una empresa de Scribd logo
1 de 3
SOLUTIONJUG.COM
COMP/220 iLab 7 of 7 - C++ Course
CLICK HERE TO GET THE SOLUTION !!!!!!!!
iLab 7 of 7: Polymorphism
i L A B O V E R V I E W
Scenario and Summary
This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract
classes, and virtual class functions. This will be done in the context of performing calculations on
basic geometrical shapes. Polymorphism is a very powerful extension of inheritance, and by using
pointers to the base class, it allows access to derived class objects and their functions based on the
context that they are called in.
The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle
and Rectangle, that are derived public from the class Shape. From there, objects of both the Circle
and the Rectangle classes will be created, as will an array of pointers to the base class Shape. By
using the instantiated objects and the object pointers, both static and dynamic binding will be
demonstrated.
Deliverables
1. Submit a single NotePad file containing the source code for all the lab files to the Week 7
Dropbox. Your source code should use proper indentation and be error free. Be sure that your last
name and the lab number are part of the file name: for example, YourLastName_Lab5.txt.
Each program should include a comment section that includes, at a minimum, your name, the lab
and exercise number, and a description of what the program accomplishes.
2. Submit a lab report (a Word document) containing the following information to the Week 7
Dropbox.
o Include your name and the lab or lab exercise number.
o Specification: Include a brief description of what the program accomplishes, including its
input, key processes, and output.
o Test Plan: Include a brief description of the method you used to confirm that your program
worked properly. If necessary, include a clearly labeled table with test cases, predicted results, and
actual results.
o Summary and Conclusions: Write a statement summarizing your predicted and actual output,
and identify and explain any differences. For conclusions, write at least one nontrivial paragraph that
explains, in detail, either a significant problem you had and how you solved it or, if you had no
significant problems, something you learned by doing the exercise.
o A UML Diagram: This should show all the classes, class members, access specifiers, data
types, and function arguments, along with all of the class-to-class relationships.
o Answers to Lab Questions: Include the answers to all the lab questions that are asked in the
lab steps.
Each lab exercise should have a separate section in the lab-report document.
Your lab grade is based upon
1. the formatting of your source code;
2. the use of meaningful identifiers;
3. the extent of the internal documentation;
4. the degree to which an exercises' specifications are met; and
5. the completeness of your lab report.
i L A B S T E P S
STEP 1: Create a New Multifile Project
Create a new multifile project with three classes: the base class Shape, the class Circle (derived
public from Shape), and the class Rectangle (derived public from Shape). The classes will have the
following requirements.
1. The class Shape should be an abstract class with the following pure virtual functions.
a. area()
b. perimeter()
2. The class Circle should be derived public from the class Shape and override both the area()
and the perimeter() functions.
a. The perimeter() function should correctly calculate the circumference of a circle, given a
radius.
b. The area() function should correctly calculate the area of a circle, given a radius
c. Include all the necessary accessor and mutator functions to accomplish the requirements of
the class.
3. The class Rectangle should be derived public from the class Shape and override both the
area() and the perimeter() functions.
a. The perimeter() function should correctly calculate the circumference of a rectangle, given its
dimensions.
b. The area() function should correctly calculate the area of a rectangle, given its dimensions.
c. Include all the necessary accessor and mutator functions to accomplish the requirements of
the class.
STEP 2: Create the Test Function
Instantiate at least one object of each of the Circle and the Rectangle classes. Provide appropriate
constructors for both that will accept the necessary initialization arguments to provide the
information required for all the class member functions. Exercise and test each member function of
both classes for correct calculations and output.
STEP 3: Add a Base Class Pointer Array and an Additional Function
Add to the test function a base class array of pointers of the same dimension as the total number of
Circle and Rectangle objects that were created in the previous step. Use this pointer array to access
the Circle and the Rectangle objects to call a new, nonclass member function that will display all the
information about each object.
1. Circle objects should display radius, circumference, and area.
2. Rectangle objects should display dimensions, perimeter. and area.
The information-display function should accept as its calling parameter a pointer of the class Shape.
Run the test function to demonstrate static (early) binding using the derived class objects calling
their member functions, and run the test function to demonstrate dynamic (late) binding using the
assigned Shape class pointers to call the nonclass, member-display-information function.
CLICK HERE TO GET THE SOLUTION !!!!!!!!

Más contenido relacionado

La actualidad más candente

Data structures and algorithms lab2
Data structures and algorithms lab2Data structures and algorithms lab2
Data structures and algorithms lab2
Bianca Teşilă
 
Data structures and algorithms lab3
Data structures and algorithms lab3Data structures and algorithms lab3
Data structures and algorithms lab3
Bianca Teşilă
 
9781111530532 ppt ch14_quick_sort
9781111530532 ppt ch14_quick_sort9781111530532 ppt ch14_quick_sort
9781111530532 ppt ch14_quick_sort
Terry Yoast
 
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya UdagedaraLambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Jaliya Udagedara
 
9781111530532 ppt ch09
9781111530532 ppt ch099781111530532 ppt ch09
9781111530532 ppt ch09
Terry Yoast
 
UnCoRe-YvesSerena
UnCoRe-YvesSerenaUnCoRe-YvesSerena
UnCoRe-YvesSerena
Serena King
 

La actualidad más candente (18)

Data structures and algorithms lab2
Data structures and algorithms lab2Data structures and algorithms lab2
Data structures and algorithms lab2
 
Data structures and algorithms lab3
Data structures and algorithms lab3Data structures and algorithms lab3
Data structures and algorithms lab3
 
9781111530532 ppt ch14_quick_sort
9781111530532 ppt ch14_quick_sort9781111530532 ppt ch14_quick_sort
9781111530532 ppt ch14_quick_sort
 
Intake 38 2
Intake 38 2Intake 38 2
Intake 38 2
 
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya UdagedaraLambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
 
A08
A08A08
A08
 
Assignment 1
Assignment 1 Assignment 1
Assignment 1
 
Hemajava
HemajavaHemajava
Hemajava
 
CIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in JavaCIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in Java
 
Method of java
Method of javaMethod of java
Method of java
 
evaluation rules
evaluation rulesevaluation rules
evaluation rules
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
Intake 38 12
Intake 38 12Intake 38 12
Intake 38 12
 
9781111530532 ppt ch09
9781111530532 ppt ch099781111530532 ppt ch09
9781111530532 ppt ch09
 
UnCoRe-YvesSerena
UnCoRe-YvesSerenaUnCoRe-YvesSerena
UnCoRe-YvesSerena
 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual
 
Ppt chapter11
Ppt chapter11Ppt chapter11
Ppt chapter11
 
Intake 37 1
Intake 37 1Intake 37 1
Intake 37 1
 

Similar a Comp 220 ilab 7 of 7

Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variables
ccis224477
 
Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variables
cis247
 
Cis247 i lab 3 overloaded methods and static methods variables
Cis247 i lab 3 overloaded methods and static methods variablesCis247 i lab 3 overloaded methods and static methods variables
Cis247 i lab 3 overloaded methods and static methods variables
sdjdskjd9097
 
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docxCSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
faithxdunce63732
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labs
ccis224477
 
Cis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee classCis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee class
ccis224477
 
Cis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee classCis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee class
cis247
 
Cis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classCis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee class
sdjdskjd9097
 
Cis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classCis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee class
sdjdskjd9097
 
1 Project 2 Introduction - the SeaPort Project seri.docx
1  Project 2 Introduction - the SeaPort Project seri.docx1  Project 2 Introduction - the SeaPort Project seri.docx
1 Project 2 Introduction - the SeaPort Project seri.docx
honey725342
 
EN3085 Assessed Coursework 1 1. Create a class Complex .docx
EN3085 Assessed Coursework 1  1. Create a class Complex .docxEN3085 Assessed Coursework 1  1. Create a class Complex .docx
EN3085 Assessed Coursework 1 1. Create a class Complex .docx
gidmanmary
 

Similar a Comp 220 ilab 7 of 7 (20)

17515
1751517515
17515
 
Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variables
 
Lecture 2 classes i
Lecture 2 classes iLecture 2 classes i
Lecture 2 classes i
 
Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variables
 
Cis247 i lab 3 overloaded methods and static methods variables
Cis247 i lab 3 overloaded methods and static methods variablesCis247 i lab 3 overloaded methods and static methods variables
Cis247 i lab 3 overloaded methods and static methods variables
 
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docxCSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
 
Lab Manual-OOP.pdf
Lab Manual-OOP.pdfLab Manual-OOP.pdf
Lab Manual-OOP.pdf
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labs
 
The Ring programming language version 1.9 book - Part 85 of 210
The Ring programming language version 1.9 book - Part 85 of 210The Ring programming language version 1.9 book - Part 85 of 210
The Ring programming language version 1.9 book - Part 85 of 210
 
Cis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee classCis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee class
 
Cis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee classCis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee class
 
Cis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classCis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee class
 
Cis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classCis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee class
 
1 Project 2 Introduction - the SeaPort Project seri.docx
1  Project 2 Introduction - the SeaPort Project seri.docx1  Project 2 Introduction - the SeaPort Project seri.docx
1 Project 2 Introduction - the SeaPort Project seri.docx
 
Prelim Project OOP
Prelim Project OOPPrelim Project OOP
Prelim Project OOP
 
Ecet 370 Education Organization -- snaptutorial.com
Ecet 370   Education Organization -- snaptutorial.comEcet 370   Education Organization -- snaptutorial.com
Ecet 370 Education Organization -- snaptutorial.com
 
SE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUSSE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUS
 
ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com
 
EN3085 Assessed Coursework 1 1. Create a class Complex .docx
EN3085 Assessed Coursework 1  1. Create a class Complex .docxEN3085 Assessed Coursework 1  1. Create a class Complex .docx
EN3085 Assessed Coursework 1 1. Create a class Complex .docx
 
Devry CIS 247 Full Course Latest
Devry CIS 247 Full Course LatestDevry CIS 247 Full Course Latest
Devry CIS 247 Full Course Latest
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Comp 220 ilab 7 of 7

  • 1. SOLUTIONJUG.COM COMP/220 iLab 7 of 7 - C++ Course CLICK HERE TO GET THE SOLUTION !!!!!!!! iLab 7 of 7: Polymorphism i L A B O V E R V I E W Scenario and Summary This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract classes, and virtual class functions. This will be done in the context of performing calculations on basic geometrical shapes. Polymorphism is a very powerful extension of inheritance, and by using pointers to the base class, it allows access to derived class objects and their functions based on the context that they are called in. The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle and Rectangle, that are derived public from the class Shape. From there, objects of both the Circle and the Rectangle classes will be created, as will an array of pointers to the base class Shape. By using the instantiated objects and the object pointers, both static and dynamic binding will be demonstrated. Deliverables 1. Submit a single NotePad file containing the source code for all the lab files to the Week 7 Dropbox. Your source code should use proper indentation and be error free. Be sure that your last name and the lab number are part of the file name: for example, YourLastName_Lab5.txt. Each program should include a comment section that includes, at a minimum, your name, the lab and exercise number, and a description of what the program accomplishes. 2. Submit a lab report (a Word document) containing the following information to the Week 7 Dropbox. o Include your name and the lab or lab exercise number. o Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output. o Test Plan: Include a brief description of the method you used to confirm that your program worked properly. If necessary, include a clearly labeled table with test cases, predicted results, and actual results. o Summary and Conclusions: Write a statement summarizing your predicted and actual output, and identify and explain any differences. For conclusions, write at least one nontrivial paragraph that explains, in detail, either a significant problem you had and how you solved it or, if you had no significant problems, something you learned by doing the exercise. o A UML Diagram: This should show all the classes, class members, access specifiers, data types, and function arguments, along with all of the class-to-class relationships.
  • 2. o Answers to Lab Questions: Include the answers to all the lab questions that are asked in the lab steps. Each lab exercise should have a separate section in the lab-report document. Your lab grade is based upon 1. the formatting of your source code; 2. the use of meaningful identifiers; 3. the extent of the internal documentation; 4. the degree to which an exercises' specifications are met; and 5. the completeness of your lab report. i L A B S T E P S STEP 1: Create a New Multifile Project Create a new multifile project with three classes: the base class Shape, the class Circle (derived public from Shape), and the class Rectangle (derived public from Shape). The classes will have the following requirements. 1. The class Shape should be an abstract class with the following pure virtual functions. a. area() b. perimeter() 2. The class Circle should be derived public from the class Shape and override both the area() and the perimeter() functions. a. The perimeter() function should correctly calculate the circumference of a circle, given a radius. b. The area() function should correctly calculate the area of a circle, given a radius c. Include all the necessary accessor and mutator functions to accomplish the requirements of the class. 3. The class Rectangle should be derived public from the class Shape and override both the area() and the perimeter() functions. a. The perimeter() function should correctly calculate the circumference of a rectangle, given its dimensions. b. The area() function should correctly calculate the area of a rectangle, given its dimensions. c. Include all the necessary accessor and mutator functions to accomplish the requirements of the class. STEP 2: Create the Test Function Instantiate at least one object of each of the Circle and the Rectangle classes. Provide appropriate constructors for both that will accept the necessary initialization arguments to provide the information required for all the class member functions. Exercise and test each member function of both classes for correct calculations and output. STEP 3: Add a Base Class Pointer Array and an Additional Function Add to the test function a base class array of pointers of the same dimension as the total number of Circle and Rectangle objects that were created in the previous step. Use this pointer array to access the Circle and the Rectangle objects to call a new, nonclass member function that will display all the information about each object. 1. Circle objects should display radius, circumference, and area. 2. Rectangle objects should display dimensions, perimeter. and area.
  • 3. The information-display function should accept as its calling parameter a pointer of the class Shape. Run the test function to demonstrate static (early) binding using the derived class objects calling their member functions, and run the test function to demonstrate dynamic (late) binding using the assigned Shape class pointers to call the nonclass, member-display-information function. CLICK HERE TO GET THE SOLUTION !!!!!!!!