test
This commit is contained in:
parent
37776af5db
commit
ab03d5f10c
4045 changed files with 286212 additions and 3 deletions
138
.config/Code/User/History/5594565a/1axD.cpp
Normal file
138
.config/Code/User/History/5594565a/1axD.cpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
138
.config/Code/User/History/5594565a/2ibQ.cpp
Normal file
138
.config/Code/User/History/5594565a/2ibQ.cpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
HotelBooking booking1(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
174
.config/Code/User/History/5594565a/4plk.cpp
Normal file
174
.config/Code/User/History/5594565a/4plk.cpp
Normal file
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
if(this->checkIn.length()!=10 || this->checkOut.length()!=10){
|
||||
cout<<"Invalid input\n";
|
||||
return;
|
||||
}
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
// subtract dates dates are in the format dd/mm/yyyy
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
if(checkInYear == checkOutYear){
|
||||
if(checkInMonth == checkOutMonth) days = checkOutDay - checkInDay;
|
||||
else days = 30 - checkInDay + checkOutDay;
|
||||
}
|
||||
else days = 30 - checkInDay + checkOutDay + 30*(checkOutMonth - checkInMonth - 1);
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
124
.config/Code/User/History/5594565a/5Rwj.cpp
Normal file
124
.config/Code/User/History/5594565a/5Rwj.cpp
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
96
.config/Code/User/History/5594565a/7qgg.cpp
Normal file
96
.config/Code/User/History/5594565a/7qgg.cpp
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails(){
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
69
.config/Code/User/History/5594565a/91ku.cpp
Normal file
69
.config/Code/User/History/5594565a/91ku.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
171
.config/Code/User/History/5594565a/B9t1.cpp
Normal file
171
.config/Code/User/History/5594565a/B9t1.cpp
Normal file
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
if(this->checkIn.length()==10 || this->checkOut.length()==10){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
if(checkInYear == checkOutYear){
|
||||
if(checkInMonth == checkOutMonth) days = checkOutDay - checkInDay;
|
||||
else days = (checkOutMonth-checkInMonth)*30 + checkOutDay - checkInDay;
|
||||
}
|
||||
else days = (checkOutYear-checkInYear)*365 + (checkOutMonth-checkInMonth)*30 + checkOutDay - checkInDay;
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
138
.config/Code/User/History/5594565a/BBtR.cpp
Normal file
138
.config/Code/User/History/5594565a/BBtR.cpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
}while(!booking1.validateBookingID());
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
149
.config/Code/User/History/5594565a/C8RP.cpp
Normal file
149
.config/Code/User/History/5594565a/C8RP.cpp
Normal file
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
137
.config/Code/User/History/5594565a/EFlb.cpp
Normal file
137
.config/Code/User/History/5594565a/EFlb.cpp
Normal file
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
HotelBooking booking1(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
}while(!booking1.validateBookingID(bookingID));
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
149
.config/Code/User/History/5594565a/EaSD.cpp
Normal file
149
.config/Code/User/History/5594565a/EaSD.cpp
Normal file
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
149
.config/Code/User/History/5594565a/EdeA.cpp
Normal file
149
.config/Code/User/History/5594565a/EdeA.cpp
Normal file
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(strlen(this->bookingID)!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
134
.config/Code/User/History/5594565a/EmCZ.cpp
Normal file
134
.config/Code/User/History/5594565a/EmCZ.cpp
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
HotelBooking booking1(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
170
.config/Code/User/History/5594565a/GBaq.cpp
Normal file
170
.config/Code/User/History/5594565a/GBaq.cpp
Normal file
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
// subtract dates dates are in the format dd/mm/yyyy
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
if(checkInYear == checkOutYear){
|
||||
if(checkInMonth == checkOutMonth) days = checkOutDay - checkInDay;
|
||||
else days = 30 - checkInDay + checkOutDay;
|
||||
}
|
||||
else days = 30 - checkInDay + checkOutDay + 30*(checkOutMonth - checkInMonth - 1);
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
124
.config/Code/User/History/5594565a/Gi4h.cpp
Normal file
124
.config/Code/User/History/5594565a/Gi4h.cpp
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails(){
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
156
.config/Code/User/History/5594565a/GmXr.cpp
Normal file
156
.config/Code/User/History/5594565a/GmXr.cpp
Normal file
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
168
.config/Code/User/History/5594565a/HVNy.cpp
Normal file
168
.config/Code/User/History/5594565a/HVNy.cpp
Normal file
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
Assignment 3
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
if(this->checkIn.length()==10 || this->checkOut.length()==10){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
days = (checkOutYear-checkInYear)*365 + (checkOutMonth-checkInMonth)*30 + checkOutDay - checkInDay;
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
174
.config/Code/User/History/5594565a/HW9H.cpp
Normal file
174
.config/Code/User/History/5594565a/HW9H.cpp
Normal file
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
if(this->checkIn.length()!=10 || this->checkOut.length()!=10){
|
||||
cout<<"Invalid input\n";
|
||||
return;
|
||||
}
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
// subtract dates dates are in the format dd/mm/yyyy
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
if(checkInYear == checkOutYear){
|
||||
if(checkInMonth == checkOutMonth) days = checkOutDay - checkInDay;
|
||||
else days = 30 - checkInDay + checkOutDay;
|
||||
}
|
||||
else days = 30 - checkInDay + checkOutDay + 30*(checkOutMonth - checkInMonth - 1);
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
138
.config/Code/User/History/5594565a/InKX.cpp
Normal file
138
.config/Code/User/History/5594565a/InKX.cpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
87
.config/Code/User/History/5594565a/Jqd9.cpp
Normal file
87
.config/Code/User/History/5594565a/Jqd9.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
121
.config/Code/User/History/5594565a/MG3L.cpp
Normal file
121
.config/Code/User/History/5594565a/MG3L.cpp
Normal file
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
175
.config/Code/User/History/5594565a/MY4n.cpp
Normal file
175
.config/Code/User/History/5594565a/MY4n.cpp
Normal file
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
int day1 = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int day2 = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int month1 = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int month2 = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int year1 = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int year2 = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
while(day1!=day2 || month1!=month2 || year1!=year2){
|
||||
days++;
|
||||
day1++;
|
||||
if(day1>30){
|
||||
day1 = 1;
|
||||
month1++;
|
||||
if(month1>12){
|
||||
month1 = 1;
|
||||
year1++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
167
.config/Code/User/History/5594565a/NpoO.cpp
Normal file
167
.config/Code/User/History/5594565a/NpoO.cpp
Normal file
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
if(this->checkIn.length()==10 || this->checkOut.length()==10){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
days = (checkOutYear-checkInYear)*365 + (checkOutMonth-checkInMonth)*30 + checkOutDay - checkInDay;
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
121
.config/Code/User/History/5594565a/Ppn3.cpp
Normal file
121
.config/Code/User/History/5594565a/Ppn3.cpp
Normal file
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
97
.config/Code/User/History/5594565a/QyGa.cpp
Normal file
97
.config/Code/User/History/5594565a/QyGa.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails(){
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
152
.config/Code/User/History/5594565a/ThSh.cpp
Normal file
152
.config/Code/User/History/5594565a/ThSh.cpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
83
.config/Code/User/History/5594565a/Ufuh.cpp
Normal file
83
.config/Code/User/History/5594565a/Ufuh.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
138
.config/Code/User/History/5594565a/Uk0I.cpp
Normal file
138
.config/Code/User/History/5594565a/Uk0I.cpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
HotelBooking booking1(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
}while(!booking1.validateBookingID(bookingID));
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
172
.config/Code/User/History/5594565a/Utj7.cpp
Normal file
172
.config/Code/User/History/5594565a/Utj7.cpp
Normal file
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
if(this->checkIn.length()==10 || this->checkOut.length()==10){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
// subtract dates dates are in the format dd/mm/yyyy
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
if(checkInYear == checkOutYear){
|
||||
if(checkInMonth == checkOutMonth) days = checkOutDay - checkInDay;
|
||||
else days = 30 - checkInDay + checkOutDay;
|
||||
}
|
||||
else days = 30 - checkInDay + checkOutDay + 30*(checkOutMonth - checkInMonth - 1);
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
144
.config/Code/User/History/5594565a/VC0u.cpp
Normal file
144
.config/Code/User/History/5594565a/VC0u.cpp
Normal file
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
152
.config/Code/User/History/5594565a/VbgQ.cpp
Normal file
152
.config/Code/User/History/5594565a/VbgQ.cpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
this->stayDuration = checkOut[0] - checkIn[0];
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
169
.config/Code/User/History/5594565a/XIi2.cpp
Normal file
169
.config/Code/User/History/5594565a/XIi2.cpp
Normal file
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
// subtract dates dates are in the format dd/mm/yyyy
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
if(checkInYear == checkOutYear){
|
||||
if(checkInMonth == checkOutMonth) days = checkOutDay - checkInDay;
|
||||
else days = 30 - checkInDay + checkOutDay;
|
||||
}
|
||||
else days = 30 - checkInDay + checkOutDay + 30*(checkOutMonth - checkInMonth - 1);
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
144
.config/Code/User/History/5594565a/ZYkV.cpp
Normal file
144
.config/Code/User/History/5594565a/ZYkV.cpp
Normal file
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
124
.config/Code/User/History/5594565a/ZssF.cpp
Normal file
124
.config/Code/User/History/5594565a/ZssF.cpp
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
67
.config/Code/User/History/5594565a/b4KS.cpp
Normal file
67
.config/Code/User/History/5594565a/b4KS.cpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
140
.config/Code/User/History/5594565a/dTYb.cpp
Normal file
140
.config/Code/User/History/5594565a/dTYb.cpp
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
1
.config/Code/User/History/5594565a/entries.json
Normal file
1
.config/Code/User/History/5594565a/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/a3/q3.cpp","entries":[{"id":"b4KS.cpp","timestamp":1711112490693},{"id":"91ku.cpp","timestamp":1711112670930},{"id":"fR08.cpp","timestamp":1711112694121},{"id":"ju6j.cpp","timestamp":1711112780270},{"id":"o9dD.cpp","timestamp":1711112801460},{"id":"Ufuh.cpp","timestamp":1711112917889},{"id":"Jqd9.cpp","timestamp":1711112957056},{"id":"zO4p.cpp","timestamp":1711113066790},{"id":"7qgg.cpp","timestamp":1711113112205},{"id":"QyGa.cpp","timestamp":1711113135808},{"id":"mcmL.cpp","timestamp":1711113168161},{"id":"uWxd.cpp","timestamp":1711113193997},{"id":"Gi4h.cpp","timestamp":1711113237973},{"id":"ZssF.cpp","timestamp":1711113278787},{"id":"5Rwj.cpp","timestamp":1711113299617},{"id":"MG3L.cpp","timestamp":1711113322957},{"id":"Ppn3.cpp","timestamp":1711175527320},{"id":"mAjx.cpp","timestamp":1711175571892},{"id":"EmCZ.cpp","timestamp":1711175644155},{"id":"mSp9.cpp","timestamp":1711792581140},{"id":"EFlb.cpp","timestamp":1711792618428},{"id":"Uk0I.cpp","timestamp":1711792645551},{"id":"2ibQ.cpp","timestamp":1711792657775},{"id":"InKX.cpp","timestamp":1711792699585},{"id":"BBtR.cpp","timestamp":1711792739444},{"id":"1axD.cpp","timestamp":1711792759884},{"id":"dTYb.cpp","timestamp":1711792774981},{"id":"qtoO.cpp","timestamp":1711792863729},{"id":"fAkw.cpp","timestamp":1711792907292},{"id":"ZYkV.cpp","timestamp":1711792920178},{"id":"VC0u.cpp","timestamp":1711793016094},{"id":"EdeA.cpp","timestamp":1711793118827},{"id":"EaSD.cpp","timestamp":1711793138993},{"id":"C8RP.cpp","timestamp":1711793213587},{"id":"fU7C.cpp","timestamp":1711793269922},{"id":"VbgQ.cpp","timestamp":1711793281221},{"id":"ThSh.cpp","timestamp":1711793299247},{"id":"MY4n.cpp","timestamp":1711793312297},{"id":"GmXr.cpp","timestamp":1711793329453},{"id":"zNWB.cpp","timestamp":1711793374362},{"id":"XIi2.cpp","timestamp":1711793449703},{"id":"GBaq.cpp","timestamp":1711793469095},{"id":"HW9H.cpp","timestamp":1711793516171},{"id":"4plk.cpp","timestamp":1711793547390},{"id":"Utj7.cpp","timestamp":1711793577819},{"id":"sHjp.cpp","timestamp":1711793636821},{"id":"kge6.cpp","timestamp":1711793786810},{"id":"B9t1.cpp","timestamp":1711793808116},{"id":"NpoO.cpp","timestamp":1711869401506},{"id":"HVNy.cpp","timestamp":1711869518416}]}
|
141
.config/Code/User/History/5594565a/fAkw.cpp
Normal file
141
.config/Code/User/History/5594565a/fAkw.cpp
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
71
.config/Code/User/History/5594565a/fR08.cpp
Normal file
71
.config/Code/User/History/5594565a/fR08.cpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
152
.config/Code/User/History/5594565a/fU7C.cpp
Normal file
152
.config/Code/User/History/5594565a/fU7C.cpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
this->stayDuration =
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
79
.config/Code/User/History/5594565a/ju6j.cpp
Normal file
79
.config/Code/User/History/5594565a/ju6j.cpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
171
.config/Code/User/History/5594565a/kge6.cpp
Normal file
171
.config/Code/User/History/5594565a/kge6.cpp
Normal file
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
if(this->checkIn.length()==10 || this->checkOut.length()==10){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
if(checkInYear == checkOutYear){
|
||||
if(checkInMonth == checkOutMonth) days = checkOutDay - checkInDay;
|
||||
else days = (checkOutMonth-checkInMonth)*30 + checkOutDay - checkInDay;
|
||||
}
|
||||
else days = 30 - checkInDay + checkOutDay + 30*(checkOutMonth - checkInMonth - 1);
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
140
.config/Code/User/History/5594565a/mAjx.cpp
Normal file
140
.config/Code/User/History/5594565a/mAjx.cpp
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
HotelBooking booking1(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
137
.config/Code/User/History/5594565a/mSp9.cpp
Normal file
137
.config/Code/User/History/5594565a/mSp9.cpp
Normal file
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
do{
|
||||
|
||||
}while(!validateBookingID(bookingID));
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
HotelBooking booking1(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
96
.config/Code/User/History/5594565a/mcmL.cpp
Normal file
96
.config/Code/User/History/5594565a/mcmL.cpp
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails(){
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
83
.config/Code/User/History/5594565a/o9dD.cpp
Normal file
83
.config/Code/User/History/5594565a/o9dD.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
140
.config/Code/User/History/5594565a/qtoO.cpp
Normal file
140
.config/Code/User/History/5594565a/qtoO.cpp
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type: ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
171
.config/Code/User/History/5594565a/sHjp.cpp
Normal file
171
.config/Code/User/History/5594565a/sHjp.cpp
Normal file
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
if(this->checkIn.length()==10 || this->checkOut.length()==10){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
if(checkInYear == checkOutYear){
|
||||
if(checkInMonth == checkOutMonth) days = checkOutDay - checkInDay;
|
||||
else days = 30 - checkInDay + checkOutDay;
|
||||
}
|
||||
else days = 30 - checkInDay + checkOutDay + 30*(checkOutMonth - checkInMonth - 1);
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
125
.config/Code/User/History/5594565a/uWxd.cpp
Normal file
125
.config/Code/User/History/5594565a/uWxd.cpp
Normal file
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails(){
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default:
|
||||
cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
175
.config/Code/User/History/5594565a/zNWB.cpp
Normal file
175
.config/Code/User/History/5594565a/zNWB.cpp
Normal file
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
HotelBooking(){}
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){
|
||||
this->stayDuration = calculateStayDuration();
|
||||
this->roomRate = calculateRoomRate();
|
||||
}
|
||||
|
||||
bool validateBookingID() const{
|
||||
if(this->bookingID.length()!=14){
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: cout<<"Invalid input\n"; return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cout<<"Invalid input\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateStayDuration() const{
|
||||
// subtract dates dates are in the format dd/mm/yyyy
|
||||
int checkInDay = (this->checkIn[0]-'0')*10 + (this->checkIn[1]-'0');
|
||||
int checkInMonth = (this->checkIn[3]-'0')*10 + (this->checkIn[4]-'0');
|
||||
int checkInYear = (this->checkIn[6]-'0')*1000 + (this->checkIn[7]-'0')*100 + (this->checkIn[8]-'0')*10 + (this->checkIn[9]-'0');
|
||||
int checkOutDay = (this->checkOut[0]-'0')*10 + (this->checkOut[1]-'0');
|
||||
int checkOutMonth = (this->checkOut[3]-'0')*10 + (this->checkOut[4]-'0');
|
||||
int checkOutYear = (this->checkOut[6]-'0')*1000 + (this->checkOut[7]-'0')*100 + (this->checkOut[8]-'0')*10 + (this->checkOut[9]-'0');
|
||||
int days = 0;
|
||||
if(checkInYear == checkOutYear){
|
||||
if(checkInMonth == checkOutMonth){
|
||||
days = checkOutDay - checkInDay;
|
||||
}
|
||||
else{
|
||||
days = 30 - checkInDay + checkOutDay;
|
||||
}
|
||||
}
|
||||
else{
|
||||
days = 30 - checkInDay + checkOutDay + 30*(checkOutMonth - checkInMonth - 1);
|
||||
}
|
||||
return days;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single") return 10;
|
||||
else if(this->roomType == "double") return 20;
|
||||
else if(this->roomType == "suite") return 50;
|
||||
}
|
||||
|
||||
int calculateTotalCost() const{
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails() const{
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
void updateBookingInfo(){
|
||||
cout<<"What would you like to update:\n";
|
||||
cout<<"1. Room Type\n";
|
||||
cout<<"2. Stay Duration\n";
|
||||
cout<<"3. Check In Date\n";
|
||||
cout<<"4. Check Out Date\n";
|
||||
cout<<"5. Exit\n";
|
||||
int choice;
|
||||
cin>>choice;
|
||||
switch(choice){
|
||||
case 1:
|
||||
cout<<"Enter new room type: ";
|
||||
cin>>this->roomType;
|
||||
break;
|
||||
case 2:
|
||||
cout<<"Enter new stay duration: ";
|
||||
cin>>this->stayDuration;
|
||||
break;
|
||||
case 3:
|
||||
cout<<"Enter new check in date: ";
|
||||
cin>>this->checkIn;
|
||||
break;
|
||||
case 4:
|
||||
cout<<"Enter new check out date: ";
|
||||
cin>>this->checkOut;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
default: cout<<"Invalid choice\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
string bookingID, customerName, hotelName, roomType, checkIn, checkOut;
|
||||
HotelBooking booking1;
|
||||
do{
|
||||
cout<<"Enter booking ID: ";
|
||||
getline(cin, bookingID);
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
}while(!booking1.validateBookingID());
|
||||
|
||||
cout<<"Enter customer name: ";
|
||||
getline(cin, customerName);
|
||||
cout<<"Enter hotel name: ";
|
||||
getline(cin, hotelName);
|
||||
cout<<"Enter room type(single, double, suite): ";
|
||||
getline(cin, roomType);
|
||||
cout<<"Enter check in date: ";
|
||||
getline(cin, checkIn);
|
||||
cout<<"Enter check out date: ";
|
||||
getline(cin, checkOut);
|
||||
|
||||
booking1 = HotelBooking(bookingID, customerName, hotelName, roomType, checkIn, checkOut);
|
||||
|
||||
booking1.getBookingDetails();
|
||||
booking1.updateBookingInfo();
|
||||
booking1.getBookingDetails();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
92
.config/Code/User/History/5594565a/zO4p.cpp
Normal file
92
.config/Code/User/History/5594565a/zO4p.cpp
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class HotelBooking{
|
||||
string bookingID;
|
||||
string customerName;
|
||||
string hotelName;
|
||||
string roomType;
|
||||
string checkIn;
|
||||
string checkOut;
|
||||
int stayDuration;
|
||||
double roomRate;
|
||||
|
||||
public:
|
||||
// iniitalzing cstr
|
||||
HotelBooking(string bookingID, string customerName, string hotelName, string roomType, string checkIn, string checkOut) :
|
||||
bookingID(bookingID), customerName(customerName), hotelName(hotelName), roomType(roomType), checkIn(checkIn), checkOut(checkOut){}
|
||||
|
||||
bool validateBookingID() const{
|
||||
for(int i=0;this->bookingID[i]!='\0';i++){
|
||||
if(i<8){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if(i<10){
|
||||
switch(this->bookingID[i]){
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '0'...'9':
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(i<14){
|
||||
switch(this->bookingID[i]){
|
||||
case '0'...'9':
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int i=0;i<4;i++) sum += this->bookingID[i+10] - '0';
|
||||
return sum<18;
|
||||
}
|
||||
|
||||
int calculateRoomRate() const{
|
||||
if(this->roomType == "single"){
|
||||
return 10;
|
||||
}
|
||||
else if(this->roomType == "double"){
|
||||
return 20;
|
||||
}
|
||||
else if(this->roomType == "suite"){
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTotalCost(){
|
||||
return this->roomRate*this->stayDuration;
|
||||
}
|
||||
|
||||
void getBookingDetails(){
|
||||
cout<<"Booking ID: "<<this->bookingID<<endl;
|
||||
cout<<"Room Type: "<<this->roomType<<endl;
|
||||
cout<<"Stay Duration: "<<this->stayDuration<<endl;
|
||||
cout<<"Room Rate: "<<this->roomRate<<endl;
|
||||
cout<<"Total Cost: "<<calculateTotalCost()<<endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue