Lab 05
Lab 05
Lab Manual 05
Object Oriented Programming
Section BCS-2A
Semester Spring 2021
TASK 1:
3- Define set functions for length and width. These should check that the values are
greater than zero, else these function should print “length should be greater than zero”
“width should be greater than zero”. Name of functions should be like “set_length()”
4- Define calculate area function, it should set the area =length*width.
5- Define a get functions for all 3 member variables. Function names should like
“get_length()”
6- Create a function is_square() it should return True if length=width of rectangle else
false.
7- Define a function to display() rectangle. It should print a rectangle using *, for
example if length =3 and width = 9, display should print
*********
*********
*********
TASK 2:
3- Define set functions of length width and height. These values cannot be <=0
4- Define get functions for all the member variables.
5- Define a function to calculate area of cube.
6- Define a function to calculate volume of cube. This should calculate and return
volume= W*H*L
7- Define a display function to display length, width, height and volume.
8- Define a function is_cube() which will return true if W=L=H else return false.
TASK 3:
- Create the main.
-
- Create an object of type rectangle in main
- Try to set the length and width to 0, -1, it should print message.
- Set its length and width to 3 and 9 resp.
- Call calculate_area function
- Use cout and get functions to print the length width and area of rectangle.
- Call display rectangle function to print it using *s.
- Call is_square() function for this rectangle.
TASK 4:
Define and Implement all functions of following point class and design a Main driver to test
all functions.