0% found this document useful (0 votes)
83 views2 pages

Task # 1:: 1 OOP Special Section Azka - Saddiqa@pucit - Edu.pk

This document provides instructions for Object Oriented Programming Lab Tasks 3 and 4. It outlines three tasks: 1) Writing a function to remove the first occurrence of a key from an array, 2) Implementing a Circle class with methods for setting properties, calculating areas and perimeters, comparing circles, and updating arrays of circles, and 3) Implementing a Vector class in three dimensions with methods for setting properties, calculating magnitudes, adding vectors, comparing vectors, and updating arrays of vectors. Students are instructed to work individually, follow coding conventions, and email their solutions to the provided email address with a specific subject line format.

Uploaded by

Asad Latif
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)
83 views2 pages

Task # 1:: 1 OOP Special Section Azka - Saddiqa@pucit - Edu.pk

This document provides instructions for Object Oriented Programming Lab Tasks 3 and 4. It outlines three tasks: 1) Writing a function to remove the first occurrence of a key from an array, 2) Implementing a Circle class with methods for setting properties, calculating areas and perimeters, comparing circles, and updating arrays of circles, and 3) Implementing a Vector class in three dimensions with methods for setting properties, calculating magnitudes, adding vectors, comparing vectors, and updating arrays of vectors. Students are instructed to work individually, follow coding conventions, and email their solutions to the provided email address with a specific subject line format.

Uploaded by

Asad Latif
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/ 2

Object Oriented Programming

Lab#03 & 04

Special OOP Section(NC)

Instructions:

• Work on your own in the lab task. No collaboration is allowed; otherwise it would result in
'F'. You can use your books, notes, handouts etc.
• To get full credit of your efforts, follow the coding conventions as well as the comments
section that describes your logic to the teacher assistant.
• Email the lab to the email [email protected] with a proper subject of following
format: [RollNum]-Lab(3 +4).

Task # 1:

Write the function that searches the array for the item key. If key is found, its first occurrence is
removed; all the elements above that position are shifted down, size is decreased, and true is
returned to indicate a successful operation. If key is not found, the array remains unchanged and
false is returned. Test the functionality in main function

bool remove_First_Occ(float a[], int &size, float key); (10 marks)

Task # 2:

ADT: Circle
1) Data Members: An integer named x and y that holds the x-axis and y-axis of a
circle respectively. A float named radius that holds the radius of a circle. 4. A constant double
named PI that holds the pi’s value i.e. 3.14159.
2) Provide the implementation of appropriate accessor(Getter) functions.
3) Provide the implementation of appropriate mutator(Setters) functions.
4) Provide the implementation of following member functions:
 setCircle(): accepts Circle’s x, y coordinates and radius as arguments and assigns
them to the appropriate member variables.
 getCircle ():initialize the data of a circle taken from the user.
 putCircle(): display the information of a particular circle.
 getArea(): calculate and return the area of a circle.
 getDiameter(): calculate and return the diameter of a circle that is radius
 getCircumference(): calculate and return the circumference of a circle
 addCircle() method should accept two circle objects and return there sum.

1 OOP Special Section


[email protected]
 isEqual() : accept two circle object and return true if they are having same state,
false otherwise.
 find(): should accept an array of Circle objects and return the index of the array
which is equal to left hand side object, -1 otherwise.
 update(): accept an array of Circle objects with its size and update the radius of
all those objects to the radius of left hand side object exist in the array having same
x, y coordinates as of left hand side object.
Test the functionality of Circle in driver program. (20 Marks)
Task # 3:

ADT: Vector
You have already heard about vector in your intermediate classes. A vector is frequently
represented by a line segment having a definite direction along with magnitude. You have to
implement the Vector ADT in three dimensional space i.e. represented by three scalar components.

1) Define appropriate data members in private area of class. All other functions should be
declared in public section.
2) Provide the implementation of all constructor, including copy constructor.
3) Provide the implementation of appropriate accessor(Getter) functions.
4) Provide the implementation of appropriate mutator(Setters) functions.
5) Provide the implementation of following member functions:
 setVector(): accepts scalar components arguments and assigns them to the
appropriate member variables.
 getVector ():initialize the data of a vector taken from the user.
 putVector(): display the information of a particular vector on console.
 isNull().: Determine if vector is a null vector or not.
 isUnit(): Determine if vector is unit vector or not.
 getMag() : return the magnitude of left hand side object..
 addCircle() method should accept two vector objects and return a vector object
that contains the sum of these two vector components.
 isEqual() : accept two vector object and return true if they are having same state,
false otherwise.
 find(): should accept an array of Vector objects and return the index of the array
which is equal to left hand side object, -1 otherwise.
 update(): accept an array of Vector objects with its size and update the third scalar
components of all those objects to the third component of left hand side object
exist in the array, having same first two components.
Test the functionality of Vector in driver program. (20 Marks)

Best of Luck!
2 OOP Special Section
[email protected]

You might also like