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

Object Oriented Programming Lab-1 + 2 Special Section - C335 Instructions

This document provides instructions for two programming assignments on object-oriented programming. It outlines three tasks: [1] Write a program to display the table of an integer value from a starting to ending limit, [2] Write a program to convert words in a sentence to Pig Latin, [3] Define a SchoolBus class with private data members and public methods to set/get bus attributes and book/cancel seats. The tasks are to be completed individually, proper coding conventions should be followed, and assignments emailed by a specified deadline.

Uploaded by

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

Object Oriented Programming Lab-1 + 2 Special Section - C335 Instructions

This document provides instructions for two programming assignments on object-oriented programming. It outlines three tasks: [1] Write a program to display the table of an integer value from a starting to ending limit, [2] Write a program to convert words in a sentence to Pig Latin, [3] Define a SchoolBus class with private data members and public methods to set/get bus attributes and book/cancel seats. The tasks are to be completed individually, proper coding conventions should be followed, and assignments emailed by a specified deadline.

Uploaded by

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

Object Oriented Programming

Lab- 1 + 2

Special Section- C335

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.
• NO Evaluation will be done after lab.

• 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(1+2).

Task # 1:

Write a program that will take three parameters of integer type from user and display the table of
the required value from the starting limit to ending limit (starting limit < ending limit). The first
parameter will be the table value, second will be the starting limit and third will be the ending
limit. See the sample output for reference. (10 marks)

Sample Execution
Enter table value: 2 Enter table value: 2
Enter starting limit: -1 Enter starting limit: 0
Enter ending limit: -5 Enter ending limit: 8
Error, invalid starting limit, 2x0=0
ending limit must be greater
2 x 1= 2
than starting limit
. . . .
2 x 8 = 16

1 OOP Special Section


[email protected]
Task # 2:

Write a program that reads a sentence (maximum 100 characters) as input and converts each
word to “Pig Latin.” In one version, to convert a word to Pig Latin you remove the first letter and
place that letter at the end of the word. Then you append the string “ay” to the word. (10 marks)

Here is an example:
English:
I SLEPT MOST OF THE NIGHT
Pig Latin:
IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY

Task # 3:

ADT: SchoolBus

Write a class named SchoolBus that has the following characteristic:

1) The class should have following three private data members


 A string named busNo that holds the license number.
 A string named owner that holds the owner’s name of the school bus.
 An integer named capacity that holds the students’ capacity inside bus.

2) Constructors: Implement the following constructors and a destructor.


a. The constructor should accept the license number and owner as arguments and
assign it to the respective member variables. The constructor should also assign 0
to the capacity member variable.
b. A copy constructor to initialize a schoolbus object with already existing object
c. A destructor that do nothing except displaying a simple message “Destructor is
executed…”

3) Provide the implementation of appropriate accessor functions to get the values stored in
an object’s busNo, owner, and capacity member variables.
4) Provide the implementation of appropriate mutator functions to set the values of object’s
busNo, owner, and capacity member variables.
5) Provide the implementation of following member functions:
 setSchoolBus(): accepts busNo, owner, and capacity as arguments and assigns them
to the appropriate member variables.

2 OOP Special Section


[email protected]
 getSchoolBus(): method to initialize the data of a bus taken from the user.
 putSchoolBus(): method to display the information of a particular bus.
 bookSchoolBus(): method adds 1 to the capacity member variable each time it is
called.
 cancelBooking(): method subtract 1 from the capacity member variable each time it
is called.

6) Test all of your functions in main function, and also creates three objects of SchoolBus
with following data with the following format:

BusNo Owner Capacity


LHR 3216 Bilal Travels 20
KHI 3317 Hamza Travels 22
FSD 5467 Hassan Travels 18

(20 Marks)

3 OOP Special Section


[email protected]

You might also like