0% found this document useful (0 votes)
2 views3 pages

Lab 05

This lab manual outlines tasks for learning object-oriented programming concepts using C++. It includes creating classes for Rectangle and Cuboid with functions for setting dimensions, calculating area and volume, and displaying results. The manual also specifies testing these functionalities through a main driver program.

Uploaded by

Aiyshah Meerab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Lab 05

This lab manual outlines tasks for learning object-oriented programming concepts using C++. It includes creating classes for Rectangle and Cuboid with functions for setting dimensions, calculating area and volume, and displaying results. The manual also specifies testing these functionalities through a main driver program.

Uploaded by

Aiyshah Meerab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

National University of Computer and Emerging Sciences

Lab Manual 05
Object Oriented Programming

Date: 16th April, 2021

Course Instructor Ms. Abeeda Akram

Lab Instructor (s) Mr. Dilawar Shabbir


Ms. Siddiqua Nayyer

Section BCS-2A
Semester Spring 2021

Department of Computer Science


FAST-NU, Lahore, Pakistan
Objectives:
1- To learn the concept of classes
2- To create and implement classes in C++

TASK 1:

1- Create a class named Rectangle.


2- Define its private variables length, width, variable area.

Inside this class make these functions:

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:

1- Create a class named Cuboid.


2- Define its private variables length, width, height,

Inside this class make these functions:

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.

- Create and object of type cuboid in main.


- Try to set the L, W, H to 0, -1, 0 it should print message.
- Set its height, length and width to 10, 10 and 10 resp.
- Call get_volume() and print the volume using cout in main
- Use cout and get functions to print the L, W, H and volume of cuboid.
- Call displace function to print the values of L, W, H and volume of cuboid.
- Call is cube function for this cuboid and print the returned value.

TASK 4:
Define and Implement all functions of following point class and design a Main driver to test
all functions.

You might also like