[go: up one dir, main page]

0% found this document useful (0 votes)
30 views1 page

Assignment 04 (Email Before 11:59 Saturday Night, 1 Minute Before Sunday)

The document describes an object-oriented programming assignment to create classes for different shapes like Rectangle, Circle, Triangle, and Ellipse. The Shape class is an abstract base class with pure virtual functions for calculating area and perimeter. The child classes implement these functions differently based on each shape's properties. A Canvas class is also described that can contain multiple shape objects and display their area and perimeter values.

Uploaded by

Sadiq Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views1 page

Assignment 04 (Email Before 11:59 Saturday Night, 1 Minute Before Sunday)

The document describes an object-oriented programming assignment to create classes for different shapes like Rectangle, Circle, Triangle, and Ellipse. The Shape class is an abstract base class with pure virtual functions for calculating area and perimeter. The child classes implement these functions differently based on each shape's properties. A Canvas class is also described that can contain multiple shape objects and display their area and perimeter values.

Uploaded by

Sadiq Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

OOP BSSE Spring 2015

Assignment 04
(Email before 11:59 Saturday night, 1 minute before Sunday)
Create class Shape. Shape has pure virtual functions to calculate area & perimeter. Create child
classes of Shape Rectangle, Circle, & Triangle.
- Rectangle has 4 data members start x, start y, width & length
- Circle has data member center x, center y & radius
- Triangle has x1, y1, x2, y2, x3, y3 i.e. 6 end points
Create Non-Parameterized constructor in all classes. Inside, initialize all data members randomly
between 1-10. Overwrite pure virtual functions of Parent class, see formula from Google.
Create class Ellipse child class of Circle, add another data member radius 2 because ellipse has two
radius. One is radius x & other is radius y. Implement calculate area & calculate perimeter function
in Ellipse class.
Create class Canvas. Canvas has data members count of shapes. Take a double pointer of type
Shape. Create parameterized constructor with integer variable. Inside constructor declare pointer
array of Shape according to count. Run a loop count time, inside loop generate random number 0-3
both inclusive and assign objects of different classes according to criteria:
- Create object of Rectangle, if number is 0
- Create object of Circle, if number is 1
- Create object of Triangle, if number is 2
- Create object of Ellipse, if number is 3
Create show function display area & perimeter of all objects by calling their respective functions.

------------------- Start with Bismillah & End with Alhumdulillah, May Allah be with you ------------------

Resource Person: Abdul Mateen Page 1 of 1

You might also like