1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
#include <iostream>
#include <iomanip>
#include <string>
#include <conio.h>
#include "Room.h"
using namespace std;
Room::Room()
{
head = NULL;
int count = 0;
}
void Room::Menu()
{
cout << "Welcome to Five Star Hotel" << endl;
cout << "**************************" << endl;
cout << "" << endl;
cout << "\tMENU" << endl;
cout << "1. Add room" << endl;
cout << "2. Drop room" << endl;
cout << "3. View data" << endl;
cout << "4. Edit data" << endl;
cout << "5. Exit " << endl;
cout << "Please select your choice: " << endl;
}
void Room::addRoom()
{
cout << "Please enter your information: " << endl;
cout << " Enter Your Id = ";
cin >> id;
cout << " Enter Your Name = ";
cin >> name;
cout << " Enter Your Phone Number = ";
cin >> phone;
cout << " Room type" << endl;
cout << "\n1.single\n2.double\n3.supreme\n:";
cin >> roomType;
cout << "Room Number ";
cin >> roomNumber;
cout << "No of bed: ";
cin >> bed;
cout << "No. of Table: ";
cin >> table;
cout << "No. of Towel: ";
cin >> towel;
cout << "No. of Sofa: ";
cin >> sofa;
cout << "Room Registered." << endl;
Node *p;
if (head == NULL)
{
head = new Node(roomNumber, roomType, bed, table, towel, sofa, NULL);
}
else
{
p = head;
while (p->next != NULL)
p = p->next;
p->next = new Node(roomNumber, roomType, bed, table, towel, sofa, NULL);
}
//count ++;
}
void Room::deleteRoom(int x)
{
Node *del = NULL;
Node *temp = head;
Node *second = head;
while (second != NULL && (second->roomNumber) != x)
{
temp = second;
second = second->next;
}
if (second == NULL)
{
cout << x << "No Room Found" << endl;
}
else
{
del = second;
second = second->next;
temp->next = second;
if (del == head)
{
head = head->next;
temp = NULL;
}
delete del;
cout << "Room number " << x << " was deleted" << endl;
}
}
void Room::viewRoom()
{
Node *p;
p = head;
cout << "Enter Customer's ID: ";
cin >> id;
if (p != NULL)
cout << "Room Number: " << p->roomNumber << "\nRoom Type: " << p->roomType << "\nNumber of bed: " << p->bed << "\nNumber of Table: " << p->table << "\nNumber of Towel: " << p->towel << "\nNumber of sofa: " << p->sofa;
else
cout << "Room not found.\n";
}
void Room::editRoom()//This function is to edit customer details in the system
{
int editing = 0; int typee = 0;
Node *second = head;
cout << " Enter id: ";
int id;
cin >> id;
while (second != NULL && (second->id) != id)
{
second = second->next;
}
if (second == NULL)
{
cout << id << " No Data Edited" << endl;
return;
}
cout << " 1.Edit Name\n 2.Edit Phone Number";
cin >> typee;
if (typee == 1)
{
cout << " Enter Your New Name : " << endl;
string newname;
cin >> newname;
second->name = newname;
cout << " The name for id number " << id << " was edited." << endl;
}
if (typee == 2)
{
cout << "Please Enter Your New Phone Number";
int newhp;
cin >> newhp;
while (second != NULL && (second->id) != id)
{
second = second->next;
}
if (second == NULL)
{
cout << id << " No Data Edited" << endl;
}
else
{
second->phone = newhp;
cout << "The contact number for id umber " << id << " was edited." << endl;
}
}
}
int main()
{
Room a1;
Main:
a1.Menu();
int choice = 0;
cin >> choice;
switch (choice)
{
case 1:
system("cls");
a1.addRoom();
system("pause");
system("cls");
goto Main;
break;
case 2:
system("cls");
cout << "Enter Room Number: ";
cin >> roomNumber;
char a;
cout << "Are you sure you want to drop this events? (y/n)" << endl;
cin >> a;
if (a == 'Y' || 'y')
{
a1.deleteRoom(roomNumber);
system("pause");
system("cls");
goto Main;
}
else if (a == 'N' || 'n')
{
system("cls");
goto Main;
}
else
{
cout << "Invalid input.\nPlease try again." << endl;
fflush(stdin);
cin.clear();
goto Main;
}
break;
case 3:
system("cls");
a1.viewRoom();
system("pause");
system("cls");
goto Main;
break;
case 4:
system("cls");
a1.editRoom();
system("pause");
system("cls");
goto Main;
break;
case 5:
break;
default:
cout << "Invalid input.\nPlease try again." << endl;
fflush(stdin);
cin.clear();
system("pause");
goto Main;
break;
}
}
|