Task # 1:: 1 OOP Special Section Azka - Saddiqa@pucit - Edu.pk
Task # 1:: 1 OOP Special Section Azka - Saddiqa@pucit - Edu.pk
Lab#03 & 04
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
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.
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]