Capital University of Science and Technology
Department of Computer Science
CS1143 Object Oriented Programming
ASSIGNMENT 03
Semester: FALL 2024 Max Marks: 10
Instructor: Muhammad Zulqarnain. Date: December 2 2024
Name: Reg. No.
INSTRUCTION:
• You have to submit two files:
o Id_Name_Assignment02.cpp
o RegNo._Name_Assignment-2.docx
• You code must be error free and in running form and your docx file also includes the
output screenshot with complete screen including system task bar.
• Plagiarized assignment will be marked as zero.
• Demo will be conducted after submission.
QUESTION NO. 01 [10]
You’re bored!
You’re looking at the students going in and out of the seating at the Cafe at CUST. You
decide to think of it as an OOP Scenario! You’re looking at the group of students arriving
at the tables outside of the dhaba, and making mental note of how long each group of
student stays at a table.
For the above scenario, let’s write a program about the tables at the Cafe.
1. Each table has some properties:
• Total available seats per table (A table can only have 4 or 8 seats)
• Seats currently occupied at a table (assume only one person can occupy
one seat)
• Free seats at a table
1
• Clean (Boolean flag representing the cleanliness of the table)
2. Each table can have some functionality associated with them:
• A default constructor – which should set the default table capacity to 4.
Initially, a table will be clean and no one will be seated on it.
• A parameterized constructor – which should set the capacity to the capacity
sent as parameter. If the number is not 4 or 8, it should be rounded to 4 or
8 (whichever is closest).
• Initially, a table will be clean and no one will be seated on it.
• Encapsulate the parameters of your class properly. The capacity should not
be editable once
• it has been set by the constructor.
• A table can be used by a group of friends – In order for the table to be used,
the table must first be clean. Whenever a group of friends is using the table,
they will decide to use the table that can fit a group of that size. (A group of
4 will be seated at a table with 4 seats, meanwhile a group of 6 will be seated
at a table with 8 seats)
• People can have lunch on the table – once the lunch is finished, the table
will no longer be clean.
• People can leave the table with or without having lunch.
• Someone can clean the table – the table can only be cleaned when no one
is seated at the table.
3. Create a global function called “OccupyTable” that accepts a Table array and size
of the group of friends. It should find a table that is not occupied and assign a table
to those people. It should mention which table has been assigned the group, and
the seating capacity of the table.
4. Create a global function called “EmptyTable” that accepts a table number and sets
it to empty. This should make proper changes to the variables present within that
table object.
5. In your main function, you are required to perform the following actions with your
Table class:
• Create an array of 5 tables.
2
▪ Two tables should be of capacity 8, and 3 should be of capacity 4.
• Call the function OccupyTable and pass the array and 4 as its parameters.
(Assume this is table 1)
• Call the function OccupyTable and pass the array and 6 as its parameters.
(Assume this is table 2)
• For table 1, call the functions for:
▪ Using the table
▪ Having lunch on the table o Leaving the table
▪ Cleaning the table
▪ Call the function EmptyTable and pass the index of table 2 as its
parameter.
3
T1: IMPLEMENTATION USING PROCEDURAL PROGRAMMING
For the scenario mentioned above, perform an implementation using procedural
programming. You have flexibility to make reasonable adjustments to the specifications,
so that the end result can be achieved.
T2: IMPLEMENTATION USING OBJECT ORIENTED PROGRAMMING
For the scenario mentioned above, perform an implementation using object oriented
programming. You have flexibility to make reasonable adjustments to the specifications,
so that the end result can be achieved.
T3: IMPLEMENTATION USING OBJECT ORIENTED PROGRAMMING WITH FILE
HANDLING
For the scenario mentioned above, perform an implementation using object oriented
programming and file handling. You have flexibility to make reasonable adjustments to
the specifications, so that the end result can be achieved.
T4: OBJECT ORIENTED VS PROCEDURAL PROGRAMMING
In this section, you are required to elaborate your understanding of object-oriented
programming in comparison with procedural programming. You are required to highlight
all differences (between OOP and PP) you identified while the implementation of
the given scenario. Your response should be based on your own understanding and
must be limited to one page only.
SUBMISSION GUIDELINES
You need to present your findings and understanding in a report format. You should use
code snippets and output snippets to demonstrate your understanding section-wise/
step-wise. Appropriate explanation should be provided along with supporting figures and
results. You should use table of contents and include captions and figure numbers for all
figures included. You need to provide your complete code at the end of the report.