TDS2111
TDS2111
TUTOR:
MR. TIMILEHIN ADERINOLA
PROJECT TITLE:
RESTAURANT ONLINE RESERVATION SYSTEM
1
TDS 2111 DATA STRUCTURES AND ALGORITHMS
2
TDS 2111 DATA STRUCTURES AND ALGORITHMS
%
A. Final Report 7 Remark
i. Introduction / Problem Statements /1
/2 Draft
ii. ADT Specification
/1 Final
iii. Implementation Details
– Justification for each data structure chosen, e.g., why do you
consider the stack data structure, but not queue?
/2
– Justification for each algorithm chosen, e.g., why do you
implement binary search, rather than other searching
algorithms?
iv. Program Screenshots
/1
v. Implementation Codes (in a CD)
B. Program Source Code 11
i. Basic functionalities, including add, edit, delete, search, sort,
display
/5
– No compilation/run-time errors
– File handling, usability, user friendliness
ii. Data Structures
– Any two data structures learned in TDS2111, including
linked-list, stack, queue, hash tables, etc. /2
– Array implementation is acceptable, but there will be no
mark given in this section.
iii. Good Programming Practices
– Code readability and cleanliness, consistent indentation
– Commendation and documentation /2
– Self-explanatory naming convention for variables and
function names
iv. Extras
– Self-defined header files, separate files for classes, exception
/2
handling, aesthetic design
– Additional functionalities, etc.
C. Program Demonstration 2
Question and Answer /2
Total / 20
3
TDS 2111 DATA STRUCTURES AND ALGORITHMS
4
TDS 2111 DATA STRUCTURES AND ALGORITHMS
5
TDS 2111 DATA STRUCTURES AND ALGORITHMS
6
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Group Member’s ID :
For the purpose of completing this project, I have performed the following tasks:
1. I hereby declare that I have assessed the final submission and I take the full responsibility should there be
any incompleteness, omissions, delays, or non-submission.
2. I also certify that not part of this project is copied from any other student’s work, or from any other
sources, except where acknowledgement is made.
Group Member’s ID :
7
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Date :
8
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Group Member’s ID :
For the purpose of completing this project, I have performed the following tasks :
3. I hereby declare that I have assessed the final submission and I take the full responsibility should there be
any incompleteness, omissions, delays, or non-submission.
4. I also certify that not part of this project is copied from any other student’s work, or from any other
sources, except where acknowledgement is made.
Group Member’s ID :
Date :
9
TDS 2111 DATA STRUCTURES AND ALGORITHMS
10
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Table of Contents
1.0 Introduction 8
2.0 ADT Specification 9
2.1 Draft ADT 9
2.2 Final ADT 13
3.0 Implementation Details 17
3.1 Data Structures Used 17
3.1.1 Singly Linked List 17
3.1.2 Vector 17
3.1.3 Nested Map 18
3.1.4 Stack 18
3.2 Algorithm Used 19
3.2.1 Sequential Search 19
3.2.2 Merge Sort 19
4.0 Program Screenshots 20
11
TDS 2111 DATA STRUCTURES AND ALGORITHMS
1.0 Introduction
With the new thinking of the current society, more people are going to restaurants for dinner
instead of making the food themselves. People started to dine in at restaurants more frequently
than ever. From festivals like New Year and Christmas to anniversaries to a normal gathering, we
have various reasons to have our dinner at a restaurant.
With the increasing popularity of restaurants, reservation quickly become more important than
ever, as many restaurants are not even accepting walk in customers due to full reservations. As
such, a digitalized restaurant reservation is very much needed. An online restaurant reservation
system is very useful for both restaurant owners and customers as it can reduces the restaurant
owners’ burden to accept, record and keep track of all reservations while enables customers to
make a reservation in an easy fashion.
Western Hut’s Online Restaurant Reservation System provides a platform for customers and the
owner to have quick information on the reservations. Customers can make and edit their
reservations by themselves through the system, without needing any extra help from the owner.
Customers only need to sign up their account to start making their reservations. For the owner,
this system can provide a great help as it can provide a list view of all reservations and
customers. Search and sort algorithms are also implemented to help the owner in obtaining
specific records easily. The system also can help the owner in improving the restaurant and the
system as it collects feedbacks from the customers.
12
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Data Items
● int reservationNo
● int date
● int time
Operations
2. ~Reservation ()
Result:
Destructor. Destroys the reservation.
4. void setReservationNo ()
Requirements:
ReservationNo are 4 digits number start from 1001 until 1999.
Result:
Set reservation number for every new reservation made.
Person ADT
A struct that groups person(customer) information of mixed data types.
13
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Data Items
● int custID
● string password
● string fullName
● int contactNo
● string email
Operations
1. void getInfo ()
Result:
Return the information of all customers.
3. void setCustID ()
Requirements:
custID must be NULL before this, as each customer could only have a unique customer ID. Active
customer is not allowed to reset the customer ID (only applicable to new customer).
Result:
New customer obtains his/her customer ID for further reservation activities.
TableReservation ADT
Child class of Reservation.
Data Items
● int tableNo
● int pplNo
● string reservationType
14
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Operations
2. ~TableReservation ()
Result:
Destructor. Destroys the TableReservation.
3. void dateAvailability ()
Result:
Determine that particular table is available on that time of date or not.
4. void addReservation ()
Requirements:
Date and time must be in future and not allowed to make reservation a day before. Must determine
whether individual or group reservation is needed.
Result:
Creates new reservation. Customer obtains the reservation number, reservationNo.
15
TDS 2111 DATA STRUCTURES AND ALGORITHMS
8. void viewAllReservation ()
Result:
Display all the reservation record.
9. void searchReservation ()
Requirements:
reservationNo must be valid (present in record).
Result:
Display particular reservation.
16
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Reservation ADT
An abstract class that has TableReservation as child class.
Data Items
● List<Customer>
Operations
1. void load_custList()
Result:
Load all the existed customer records from file into the linked list.
2. void addCust()
Requirements:
No duplicated customer ID is generated for new customer.
Result:
Add new customer and his/her information into the dynamic data structure, linked list.
3. void deleteCust()
Requirements:
The customer ID entered exists in customer record.
Result:
Remove particular customer record from linked list and the file.
4. void sortCust()
Result:
Sort the customers based on customer ID in ascending order or customer name either in ascending
order or descending order.
5. void displayCust()
Result:
Display all customer record.
6. void modifyCust()
Result:
Modify particular customer record.
17
TDS 2111 DATA STRUCTURES AND ALGORITHMS
8. void save_custList()
Result:
Save all the data in dynamic memory into file.
9. Void searchCust()
Result:
Search particular customer and displays his or her information.
Customer ADT
A struct that groups customer information of mixed data types.
Data Items
● int custID
● string custPassword
● string custName
● int custContact
● string custEmail
Operations
TableReservation ADT
Child class of Reservation.
18
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Data Items
● int reservTableNo
● int reservPplNo
● string reservType
● int custID
● int reservID
● int reservDate
● int reservTime
Operations
Result:
Constructor. Creates a reservation object that all the entries have values.
2. ~TableReservation()
Result:
Destructor. Destroys the TableReservation.
4. void addReserv()
Requirements:
Date and time must be in future and not allowed to make reservation a day before. Must determine
whether individual or group reservation is needed.
Result:
Creates new reservation. Customer obtains the reservation ID, reservID.
19
TDS 2111 DATA STRUCTURES AND ALGORITHMS
6. void deleteReserv()
Requirements:
reservID must be valid (present in record).
Result:
Remove the reservation based on reservation number.
7. void modifyReserv()
Requirements:
reservID must be valid (present in record). Modified date and time must be in future.
Result:
The particular reservation is updated.
8. void displayReserv()
Result:
Display all the reservation record.
9. void searchReserv()
Requirements:
reservID must be valid (present in record).
Result:
Display particular reservation.
20
TDS 2111 DATA STRUCTURES AND ALGORITHMS
21
TDS 2111 DATA STRUCTURES AND ALGORITHMS
In this project, there are a few of data structures being utilized to ensure the smooth run of
program which are:
Reservation, a class that organizes all the person information such as name, customer ID,
phone number, and email. In order to ensure the personal information are gathered together,
struct and singly linked list are used to link customer information from one to another. Whether
there is a new customer, the customer’s information into the end of linked list. Any modification
(add/delete/update) on the customer’s data will be carried out on the linked list and save into the
file.
Linked list is selected as the data structure to be used in this case as linked list is a
dynamic data structure that can grow and shrink during run time and provide ease of insertion
and deletion. Compare to array that stores a collection of similar type data elements, linked list is
a non-primitive data structure that contains a collection of unordered linked elements known as
nodes. Time complexity for both array and linked list do not have a huge difference. Other data
structures such queue and stack are totally not suitable here. Therefore, linked list is used.
22
TDS 2111 DATA STRUCTURES AND ALGORITHMS
3.1.2 Vector
Vectors are used in load function in this project as a purpose to store the substrings of the
file and pass the contents of vectors to the dynamic data structures such as linked list for further
data modification. Vector is resizable dynamic array that the size can be determined in O(1) time.
Since the data might grow from time to time, fixed size array is not preferable here. We need not
data structures like hash table, queue, stack or linked list in handling this task so vector is the
best candidate here.
Nested map is a data structure used to store the table count in each date and time. It is mainly
used in void TableReservation::checkAvailability(int& inputDate, int&
inputTime, int& rTableNo, bool& flag), when user adding a reservation. It is chosen
as one of our data structures because we need to map the table count (value) to the combination
of date and time (keys). From Figure 3.1, the outer map stores date as key and inner map as the
value, while the inner map stores time and table count. Since our program needs multiple keys,
hence other data structures are not handy to be used.
3.1.4 Stack
Stack is a data structure that follows the first in, last out (FILO) or the last in, first out
(LIFO) order. A stack is used in the sort functions to descend sort the records. It is chosen
because it has the FILO or LIFO nature, which makes it very easy to implement and does not
require too much time to develop another sorting algorithms.
23
TDS 2111 DATA STRUCTURES AND ALGORITHMS
24
TDS 2111 DATA STRUCTURES AND ALGORITHMS
● Sequential search
● Merge sort
Search functions is used to search customer record and also reservation record. Customer
record is searched using customer ID, while reservation record is searched using reservation
number. Both of the records used linked list data structure. Therefore, sequential search should
be the most suitable searching algorithm to use in our program, as linked lists do not allow
random access of their nodes.
Sort functions are used to sort customer records and reservation records for the system
admin. Customer records are originally sorted by their Customer ID, in ascending order, while
the reservation records are initially sorted by their Reservation ID, also in ascending order. The
admin can select to sort by Customer ID in descending order, or by Customer Name in both
orders for the customer records. For the reservation record, the admin can select to sort by
Reservation ID in ascending order, or by Date in both orders. All implementation of descending
order sort is done by utilizing the FILO or LIFO nature of a stack, while the ascending order sort
is done by implementing merge sort algorithm.
25
TDS 2111 DATA STRUCTURES AND ALGORITHMS
process of splitting the array and to have shorter sorting time. The sorted records will be
displayed after the merge sort.
26
TDS 2111 DATA STRUCTURES AND ALGORITHMS
27
TDS 2111 DATA STRUCTURES AND ALGORITHMS
28
TDS 2111 DATA STRUCTURES AND ALGORITHMS
29
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Figure 4.9. Message informing users that it is not allowed to make a reservation a day before
30
TDS 2111 DATA STRUCTURES AND ALGORITHMS
31
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Figure 4.12 shows the output when a user inputs an invalid month. User will be prompted to
reenter the month and the system will even provide a range that is from 1 to 12.
32
TDS 2111 DATA STRUCTURES AND ALGORITHMS
reservation type, and number of people. Pressing any key will return users to the customer main
menu.
33
TDS 2111 DATA STRUCTURES AND ALGORITHMS
34
TDS 2111 DATA STRUCTURES AND ALGORITHMS
When users log out of their account, a message as shown above in Figure 4.22 will be shown to
users before the log off. Users can choose to answer the feedback by entering yes (y/Y) or skip it
by entering no (n/N). Skipping the user feedback give an output as shown below in Figure 4.23.
35
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Figure 4.26 shows the Admin mode. Choosing to enter Admin mode will prompt users to enter
the password required. Users are strictly restricted to entering the password for a maximum
attempt of 3 times only. Just like other passwords, the passwords entered are concealed and
further elongated with “*”. Users can enter “0” to go back to the main menu too.
36
TDS 2111 DATA STRUCTURES AND ALGORITHMS
reservation, display all reservation, search reservation, modify reservation, and delete reservation
while in (B) there are functions to display all customer record, search customer record, modify
customer record, and delete customer record. Users can enter “0” to go back to the main menu
too. Users will be prompted to enter their choice of selection where 1- new reservation, 2-
display all reservation, 3- search reservation, 4- modify reservation, 5- delete reservation, 6-
display all customer record, 7- search customer record, 8- modify customer record, and 9- delete
customer record. For search, modify, and delete in (A) Reservation, it is exactly the same process
as in customer main menu.
37
TDS 2111 DATA STRUCTURES AND ALGORITHMS
38
TDS 2111 DATA STRUCTURES AND ALGORITHMS
39
TDS 2111 DATA STRUCTURES AND ALGORITHMS
Picking yes will redirect the user to a sorting function that prompts the user to pick from the
selection. Users can choose to sort by descending customer ID, ascending customer name, or
descending customer name. Users can choose by inputting 1- descending customer ID, 2-
ascending customer name, or 3- descending customer name. This is shown above in Figure 4.38.
Sample results by different selection are shown below in Figure 4.39, Figure 4.40, and Figure
4.41. After each sort is done, the user will be redirected to admin main menu after pressing any
key.
40
TDS 2111 DATA STRUCTURES AND ALGORITHMS
41
TDS 2111 DATA STRUCTURES AND ALGORITHMS
42
TDS 2111 DATA STRUCTURES AND ALGORITHMS
43