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

Oops

Uploaded by

donotaskname07
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)
21 views10 pages

Oops

Uploaded by

donotaskname07
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/ 10

Object-Oriented Programming (OOP) Project: Hotel

Management System

Table of Contents:

1. Introduction
2. Object-Oriented Concepts
o 2.1 Classes and Objects
o 2.2 Inheritance
o 2.3 Polymorphism
o 2.4 Encapsulation
o 2.5 Abstraction
3. Project Overview
o 3.1 Project Requirements
o 3.2 Problem Definition
o 3.3 Solution Approach
4. Detailed Analysis of the Code
o 4.1 Class Definitions
o 4.2 Member Functions
o 4.3 Object Creation and Function Calls
o 4.4 Function Flow
5. Code Walkthrough
o 5.1 Class: hotel

o 5.2 Class: manager

o 5.3 Class: staff

o 5.4 Class: customer


o 5.5 Main Function
6. Advantages of Using OOP
7. Improvements and Extensions
8. Challenges Encountered
9. Conclusion
10. References
1. Introduction

This project is a simple Hotel Management System implemented


using Object-Oriented Programming (OOP) concepts in C++. The
project is designed to demonstrate the practical application of OOP
principles like inheritance, encapsulation, polymorphism, and
abstraction to solve real-world problems. The Hotel Management
System is modeled using a few basic entities like the Hotel,
Manager, Staff, and Customer.

The main goal of the project is to manage and organize hotel data
efficiently, allowing the system to handle various tasks such as hotel
information management, manager details, staff records, and
customer bookings.

2. Object-Oriented Concepts

2.1 Classes and Objects

In Object-Oriented Programming, a class is a blueprint or template for


creating objects. An object is an instance of a class. Each class
defines its own properties (data members) and behaviors (member
functions).

In this project, four classes are defined:

 hotel: Manages the basic hotel information.


 manager: Inherits from hotel and stores the manager's
details.
 staff: Inherits from manager and manages staff information.
 customer: A standalone class that deals with customer details.

Each of these classes encapsulates related data and functions,


ensuring data consistency and reusability.

2.2 Inheritance
Inheritance is a key feature of OOP where one class can inherit the
properties and behaviors (methods) of another class. This promotes
code reusability and extension of existing functionality.

In this project:

 The manager class inherits from the hotel class, meaning it


can access the properties and functions of hotel.
 The staff class inherits from the manager class, meaning it
can access properties and functions from both manager and
hotel.

This hierarchical structure reduces redundancy in the code.

2.3 Polymorphism

Polymorphism allows objects of different classes to be treated as


objects of a common superclass. The behavior of polymorphism
depends on the object being referenced.

In this project, polymorphism isn't explicitly implemented since the


project doesn't demonstrate function overriding. However,
polymorphism could be applied in an extended version of the system
where a showDetails() function could be overridden in each
derived class to display class-specific information.

2.4 Encapsulation

Encapsulation refers to the bundling of data (variables) and methods


(functions) that operate on the data into a single unit, or class. In this
project, encapsulation is seen in the way each class contains its own
data members and functions.

For example, in the customer class, the customer details (like ID,
name, contact, etc.) are encapsulated within the class. The
getcust() and putcust() functions are used to interact with
this data, providing controlled access.

2.5 Abstraction
Abstraction is the concept of hiding the complex implementation
details and exposing only the necessary information to the user. In
this project, abstraction is demonstrated through the class interfaces,
where the user interacts with the methods of the classes without
needing to know the internal workings of those methods.

For example, the getcust() method in the customer class hides


the implementation of how customer data is received, and the
putcust() method hides how customer data is displayed.

3. Project Overview

3.1 Project Requirements

The basic functionality of the Hotel Management System includes:

 Displaying hotel information.


 Displaying manager details.
 Displaying staff details.
 Allowing customers to input and display their details.

The system also needs to be organized in an object-oriented way,


where the classes interact with one another based on inheritance,
encapsulation, and abstraction.

3.2 Problem Definition

Before implementing the project, the following problems were


identified:

1. Data Organization: How to organize and store hotel, manager,


staff, and customer information in an efficient manner.
2. Inheritance: How to structure the system to avoid code
duplication by using inheritance.
3. User Interaction: How to provide an interface where users can
interact with the system by entering and displaying data.
3.3 Solution Approach

The solution approach involved:

1. Creating the Hotel Class: This would store basic information


about the hotel.
2. Inheriting the Manager Class: The manager class would inherit
from the hotel class and add manager-specific data.
3. Inheriting the Staff Class: The staff class would inherit from the
manager class and add staff-specific details.
4. Creating a Separate Customer Class: The customer class would
handle customer-specific data like booking information and
contact details.

4. Detailed Analysis of the Code

4.1 Class Definitions

 hotel class: The hotel class contains basic hotel information


like the hotel name, address, and phone number. It also has the
function puthotel() to display this information.

cpp
Copy code
class hotel
{
public:
void puthotel()
{
cout << "\n Welcome Hotel Panjabi Kitchen";
cout <<
"\n*___________________________________________
______________________________*";
cout << "\n\n\n\n Register no. = IHO-
123456";
cout << "\n Address = ****";
cout << "\n Phone no. = ****";
}
};

 manager class: The manager class inherits from hotel and


adds manager-specific details such as the manager’s ID, name,
and contact number.

cpp
Copy code
class manager : public hotel
{
public:
void putmanager()
{
cout << "\n\n ID = 384756";
cout << "\n Manager = ****";
cout << "\n Contact = ****";
}
};

 staff class: The staff class inherits from manager and stores
staff information, such as staff IDs and names.

cpp
Copy code
class staff : public manager
{
public:
void putstaff()
{
cout << "\n\n Staff ID = 293874";
cout << "\n Staff1 = ****";
cout << "\n\n Staff ID = 376478";
cout << "\n Staff2 = ****";
}
};
 customer class: The customer class is independent and
contains customer details such as ID, name, contact, and room
number. It has methods getcust() to input customer data
and putcust() to display it.

cpp
Copy code
class custmer
{
int custmer_Id, contact, room_number;
char custmer_name[20], address[20];
public:
void getcust()
{
cout << "\n\n Enter customer id = ";
cin >> custmer_Id;
cout << "\n Enter customer name = ";
cin >> custmer_name;
cout << "\n Enter customer address = ";
cin >> address;
cout << "\n Enter customer contact no = ";
cin >> contact;
cout << "\n Enter room number = ";
cin >> room_number;
}

void putcust()
{
cout <<
"\n*___________________________________________
______________________________*";
cout << "\n\n\n Customer ID: " <<
custmer_Id;
cout << "\n Customer Name: " <<
custmer_name;
cout << "\n Customer Address: " << address;
cout << "\n Customer Contact: " << contact;
cout << "\n Customer Room: " <<
room_number;
cout <<
"\n*___________________________________________
______________________________*";
}
};

4.2 Member Functions

Each class has specific functions:

 puthotel(): Displays hotel details.


 putmanager(): Displays manager details.
 putstaff(): Displays staff details.
 getcust(): Accepts customer data from the user.
 putcust(): Displays customer data.

4.3 Object Creation and Function Calls

In the main() function, objects of the staff and customer


classes are created. The functions are then called using these objects
to display the required information.
cpp
Copy code
void main()
{
staff s;
custmer c;
clrscr();
s.puthotel();
s.putmanager();
s.putstaff();
c.getcust();
c.putcust();
getch();
}
4.4 Function Flow

 The main() function first clears the screen using clrscr().


 It then calls puthotel(), putmanager(), and
putstaff() to display hotel, manager, and staff details.
 Next, it calls getcust() to get customer information and
then putcust() to display that information.

5. Advantages of Using OOP

 Reusability: Inheritance allows code to be reused across


different classes, avoiding duplication.
 Maintainability: Each class handles a specific part of the
system, making it easier to update and maintain.
 Extensibility: The system can be extended by adding new
classes or modifying existing ones without affecting other parts
of the code.
 Modularity: By organizing the code into different classes, each
class can be modified or debugged independently.

6. Improvements and Extensions

 User Interface: A graphical user interface (GUI) could be added


to make the system more user-friendly.
 Database Integration: The system could be extended to
integrate with a database to store hotel, manager, staff, and
customer information persistently.
 Error Handling: Add input validation and error handling to
ensure the program handles invalid or incorrect inputs
gracefully.
7. Challenges Encountered

 Handling Data Types: Managing the data types correctly for


input and output required careful attention, especially with
strings and numeric values.
 Inheritance Issues: Ensuring that each derived class has the
correct properties and methods from the base class was an
important design challenge.

8. Conclusion

The Hotel Management System demonstrates a clear understanding


and practical application of object-oriented programming principles.
It efficiently organizes hotel, manager, staff, and customer data using
OOP concepts like inheritance, encapsulation, and abstraction. The
project can be further enhanced by integrating databases, improving
the user interface, and adding more complex functionalities.

9. References

1. C++ Programming: From Problem Analysis to Program Design


by D. S. Malik
2. Object-Oriented Programming with C++ by E. Balagurusamy
3. C++ Primer by Stanley B. Lippman, Josée Lajoie, Barbara E. Moo

You might also like