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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
|
#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 Virtual Architecture" << endl;
cout << "**************************" << endl;
cout << "**" << endl;
cout << "**-------MENU------**" << endl;
cout << "** 1. Add room **" << endl;
cout << "** 2. Drop room **" << endl;
cout << "** 3. View data **" << endl;
cout << "** 4. Edit data **" << endl;
cout << "** 5. Search Room **" << endl;
cout << "** 6. Print Room **" << endl;
cout << "** 7. Exit **" << endl;
cout << "**-----------------**" << 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, id, name, NULL);
}
else
{
p = head;
while (p->next != NULL)
p = p->next;
p->next = new Node(roomNumber, roomType, bed, table, towel, sofa, id, name, NULL);
}
//count ++;
}
void Room::deleteRoom(int x)
{
Node *del = NULL;
Node *temp = head;
Node *second = head;
while (second != NULL && ((*second).roomNumber) != roomNumber)
{
temp = second;//let temp point to watever end is pointed to
second = (*second).next;
}
if (second == NULL)
{
cout << roomNumber << " No Data Deleted" << endl;
delete del;//free memory;
}
else
{
del = second;
second = (*second).next;
(*temp).next = second;
if (del == head)
{
head = (*head).next;
temp = NULL;
}
delete del;
cout << "The value " << x << " was deleted." << endl;
}
}
void Room::viewRoom()
{
Node *second;
second = head;
while (second != NULL)
{
cout << "ID Number" << " " << "Name" << " " << "Room Number" << endl;
cout << setfill('x') << setw(5);
cout << (*second).id << " ";
cout << setfill(' ') << setw(10);
cout << (*second).name << " ";
cout << setfill(' ') << setw(10);
cout << (*second).roomNumber << " ";
second = (*second).next;
cout << "\n";
//system("pause");
//system("cls");
}
}
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 number " << id << " was edited." << endl;
}
}
}
//------------------------------------------------==SEARCH FUNCTION==------------------------------------------------------------------------
void Room::searchRoom()
{
int id;
Node *p;
cout << "Enter ID: ";
cin >> id;
p = head;
bool found = false;
while (p != NULL)
{
if (p->id == id) {
cout << "Customer's Name" << " " << "Room Number" << " " << endl;
cout << setfill(' ') << setw(10);
cout << (*p).name << " ";
cout << setfill(' ') << setw(5);
cout << (*p).roomNumber << " ";
cout << "\n";
found = true;
}
p = (*p).next;
}
if (found == false)
cout << "The ID is not in the list" << endl;
system("pause");
system("cls");
}
//------------------------------------------------==Print FUNCTION==------------------------------------------------------------------------
void Room::printRoom()
{
int choice, count = 1, count1 = 1;
Node *second;
second = head;
cout << "Enter Name to print Receipt: " << endl;
cin >> name;
cout << " " << endl;
while (second != NULL && (second->name) != name)
{
count++;
second = head->next;
}
if (second == NULL)
{
cout << "\t\t ***<-- Receipt on Virtual Architecture -->***\n" << endl;
cout << " ||Customer's Name: \n ||" << second->name;
cout << " ||Customer Phone Number : \n||" << second->phone;
cout << "___________________________________________________________________" << endl;
cout << "Room Type\tBed\tTable\t\towel \t\sofa" << endl;
cout << "___________________________________________________________________" << endl;
cout << second->roomType << "\t\t" << second->bed << "\t\t " << second->table << "\t\t" << second->towel << "\t\t" << second->sofa << endl;
second = second->next;
while (second != NULL && (second->name) == name)
{
cout << second->roomType << "\t\t" << second->bed << "\t\t " << second->table << "\t\t" << second - sofa << endl;
count1++;
second = second->next;
}
}
else
{
cout << "Error. Enter a valid name." << 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 == 'N' || 'n')
{
a1.deleteRoom(roomNumber);
system("pause");
system("cls");
goto Main;
}
else if (a == 'Y' || 'y')
{
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:
system("cls");
a1.searchRoom();
system("pause");
system("cls");
goto Main;
break;
case 6:
system("cls");
a1.printRoom();
system("pause");
system("cls");
goto Main;
break;
case 7:
break;
default:
cout << "Invalid input.\nPlease try again." << endl;
fflush(stdin);
cin.clear();
system("pause");
goto Main;
break;
}
}
|