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

OOP Lab - 2-3

The document outlines 5 tasks involving object-oriented programming concepts. Task 1 asks to create a Bike class with getter/setter methods and a print method. Task 2 involves a School class with room, staff, and student variables and initialize and print methods. Task 3 covers creating a Date class with different constructor types. Task 4 details a Car class with year, make, and speed variables along with constructor, accessor, accelerate, and brake methods. Task 5 is about designing an Inventory class to store retail item information.

Uploaded by

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

OOP Lab - 2-3

The document outlines 5 tasks involving object-oriented programming concepts. Task 1 asks to create a Bike class with getter/setter methods and a print method. Task 2 involves a School class with room, staff, and student variables and initialize and print methods. Task 3 covers creating a Date class with different constructor types. Task 4 details a Car class with year, make, and speed variables along with constructor, accessor, accelerate, and brake methods. Task 5 is about designing an Inventory class to store retail item information.

Uploaded by

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

Lab Tasks

Task 1:
Make a class of Bike with parameters strokes, horsepower with all possible getter/setter and print() and write
test program for it.

Task 2:
Make a class of School with parameters all int type: rooms, staff, students and function initialize() and print()
write test program for it.

Task 3:
Write a code for a class named Date which must incorporate the following given main write each type of
constructor implemented in following main function.

int main()
{
Date D1;
D1.DisplayDate();
Date D2(23);
D2.DisplayDate();
Date D3(23,03);
D3.DisplayDate();
Date D4(23,03,2013);
D4.DisplayDate();
return 0;
}

Task 4:

Write a class named Car that has the following member variables:
• year. An int that holds the car’s model year.
• make. A string that holds the make of the car.
• speed. An int that holds the car’s current speed.

In addition, the class should have the following member functions.

• Constructor.
The constructor should accept the car’s year and make as arguments
and assign these values to the object’s year and make member variables. The constructor
should initialize the speed member variable to 0.
• Accessors.
Appropriate accessor functions should be created to allow values to be
retrieved from an object’s year, make, and speed member variables.
• accelerate.
The accelerate function should add 5 to the speed member variable
each time it is called.
• brake.
The brake function should subtract 5 from the speed member variable each
time it is called.

1
Demonstrate the class in a program that creates a Car object, and then calls the accelerate
function five times. After each call to the accelerate function, get the current speed of the
car and display it. Then, call the brake function five times. After each call to the brake
function, get the current speed of the car and display it..

Task 5:
Design an Inventory class that can hold information for an item in a retail store’s inventory.
The class should have the following private member variables.

2
3

You might also like