Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Object Oriented Programming Lab4

Object Oriented Programming Lab


Lab 04
Marks 50

Instructions:

 VC 6 ++ is the development tool will be used.


 Work on this lab individually. Discussion is not allowed.
 You can use your books, notes, handouts etc but you are not allowed to borrow anything from
your peer student.
 Proper indentation of the code must be done.
 Evaluation of both tasks will be conducted in lab.
 You need to use this pointer in each and every member function of your created class.
 Anyone caught being indulged in the act of plagiarism would be awarded an “F” grade in this lab.

Objective:

After today’s lab you will be able:

 To understand the functionality usage and working of copy constructor and operator over loading.

Task 1: (Marks 15)

You went for shopping for your upcoming university function and have bought many items; a shirt, a tie
etc for different prices but you found that no item could be less than 100 PKR due to day to day increase
in prices.
Implement a class Product that can store the price for each item purchased. Implement the following
member function in your class

• Default constructor
• Parameterized constructor
• Copy constructor
• Getter and Setter
 Destructor

Compute and return the sum of the items with the help of a global function which receives two
parameters an array of Product type and total number of products.

Test the functionality of your class by creating an array of Product in main method.

©Fakhra Jabeen, PUCIT, Lahore Page 1


Object Oriented Programming Lab4

Task2: (15 marks)

Implement a Circle class. Each object of this class will represent a circle, storing its radius and the x and
y coordinates of its center as floats.
Include all access functions, an area() function to calculate the area of the circle which is equal to πr 2.

Make these global functions

Void BigestCircle(Circle obj[],int size); //print the radius, area and coordinate of the biggest circle

Void SmallestCircle(Circle obj[],int size); //print the radius, area and coordinate of the biggest circle

Test the functionality of your created class. Create an array of circle of size 10 in main method. Set radius
and x, y point of each object.

Task 3: (20 marks)

Create a class Fractions that have numerator and denominator as its integer members and perform
following tasks.

1. Overload operator + that add the two fractions (objects).


2. Overload operator - that subtract the two fractions (objects).
3. Overload operator * that multiply the two fractions (objects).
4. Overload operator / that divide the two fractions (objects).
BONUS PART:
5. Overload operator = that assign value of one object into other objects.

Best of Luck 

©Fakhra Jabeen, PUCIT, Lahore Page 2

You might also like