O b j e c t
Lab 03
O r i e n t e d
P r o g r a m m i n g
Lab 03
L a b
Marks 10
Instructions
Work on this lab individually. You can use your books, notes, handouts etc. but you are not allowed to borrow anything from your peer student.
Marking Criteria
Show your work to the instructor before leaving the lab to get some or full credit.
Submission
Paste the solution(s) folder of the problems (source code .cpp files only) labeled with your complete roll number in OOPM – Lab3 folder till 04:00 PM. This folder is available at \\printsrv\Teacher Data\Hassan Khan\OOP\Students
What you have to do
Program the following tasks in your Microsoft C++ compiler and then compile and execute them. The name of your files will be according to the task given in this lab.
Task 1
Create class Cylinder which will have
• an instance variable to store the radius of cylinder.
• an instance variable height indicating the height of cylinder.
• Provide a method modifyRadius(double) that sets the radius to a new value.
• Provide a method modifyHeight(double) that sets the height to a new value.
• Provide a method calculateArea() to calculate the area of a cylinder. Finally this method will return the area of cylinder.
• Provide a method calculateVoulme() to calculate the volume of a cylinder. Finally this method will return the volume of cylinder. Write a main() to run your program that will create two objects of Cylinder, cylinder1 and cylinder2, with radius of 2.00 and 3.00 meters respectively. Set height to 5 meter, then calculate the area, volume and print their values. Also make calls to all the member functions of the class to test their functionality from main().
Also do check the functionality of default copy constructor.
Task 2
Write a class named Car that has the following member variables:
•
•
•
yearModel: An int that holds the car’s year model. make: A pointer to char that holds the make of the car.