Advertisement
Guest User

postlab7

a guest
Nov 24th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Building {
  7.     string name,Address;
  8.     int level;
  9. public:
  10.     Building(string, string, int);
  11.     ~Building();
  12.     void print();
  13.     string getName();
  14.     string getAddress();
  15.     int getLevel();
  16. };
  17.  
  18. int Building::getLevel(){
  19. return level;
  20. }
  21.  
  22. string Building::getAddress(){
  23. return Address;
  24. }
  25.  
  26. string Building::getName(){
  27. return name;
  28. }
  29.  
  30. void Building::print(){
  31. cout << "Building name is " <<name<<endl;
  32. cout << "Address is "<< Address<<endl;
  33. cout << "Number of levels are "<< level<<endl;
  34. }
  35.  
  36. Building::Building(string a, string b, int c){
  37. name=a;
  38. Address=b;
  39. level=c;
  40. }
  41.  
  42. Building::~Building(){
  43. cout << "This is the Building Destructor" <<endl;
  44. }
  45.  
  46. class Restaurant:public Building{
  47. int deliveryList[5];
  48. int length;
  49. public:
  50.     Restaurant(string, string, int);
  51.     ~Restaurant();
  52.     void printMenu();
  53.     void MakeDelivery();
  54.     void  DeleteDelivery(int);
  55.    
  56. };
  57. void Restaurant::DeleteDelivery(int a){
  58.     int d=0;
  59. for(int i=0 ; i < length ;i++)
  60.     if(deliveryList[i] == a){
  61.         d = i;
  62.         break;  }
  63. for(int i=d ; i < length ;i++)
  64.     deliveryList[i]=deliveryList[i+1];     
  65. }
  66.  
  67. void Restaurant::MakeDelivery(){
  68. cout << "Enter the meal you want : ";
  69. int a; cin >> a;
  70. cout<< endl;   
  71. switch (a) {
  72. case 1:
  73.     cout << "You choose Mansaf" << endl;
  74.     deliveryList[length++] = a;
  75.     break;
  76. case 2:
  77.     cout << "You choose Kabseh" << endl;
  78.     deliveryList[length++] = a;
  79.     break;
  80. case 3:
  81.     cout << "You choose Mashawee" << endl;
  82.     deliveryList[length++] = a;
  83.     break;
  84. case 4:
  85.     cout << "You choose Molo5eh" << endl;
  86.     deliveryList[length++] = a;
  87.     break;
  88. case 5:
  89.     cout << "You choose Sea Food" << endl;
  90.     deliveryList[length++] = a;
  91.     break;
  92. default:
  93.     cout << "you enter wrong input" << endl;
  94. }}
  95.  
  96. void Restaurant::printMenu(){
  97. cout << "1. Mansaf"<<endl;
  98. cout << "2. Kabseh"<<endl;
  99. cout << "3. Mashawee"<<endl;
  100. cout << "4. Molo5eh"<<endl;
  101. cout << "5. Sea Food"<<endl;
  102. }
  103.  
  104. Restaurant::Restaurant(string a, string b, int c):Building(a,b,c){
  105.     length=0;
  106. }
  107. Restaurant::~Restaurant(){
  108. cout << "This is the Resturant Destructor" <<endl;
  109. }
  110.  
  111.  
  112. class Hotel:protected Building{
  113. protected:
  114.     int noOfroomPlevel ,noOfAvaRoom ;
  115.     Restaurant rest;
  116. public:
  117.     Hotel(string, string, int);
  118.     ~Hotel();
  119.     void print();
  120.     void setAll(int,int);
  121.     void checkIn();
  122.     void checkOut();
  123.     double Bill();
  124.     void MakeDelivery();
  125.     void DeleteDelivery(int);
  126. };
  127.  
  128. void Hotel::DeleteDelivery(int a){
  129.     rest.DeleteDelivery(a);
  130. }
  131.  
  132. void Hotel::MakeDelivery(){
  133.     rest.MakeDelivery();
  134. }
  135.  
  136.  
  137. void Hotel::checkOut(){
  138.     noOfAvaRoom++;
  139. }
  140.  
  141. void Hotel::checkIn(){
  142.     noOfAvaRoom--;
  143. }
  144.  
  145. void Hotel::setAll(int a,int b){
  146.     noOfroomPlevel = a;
  147.     noOfAvaRoom = b;
  148. }
  149.  
  150. void Hotel::print(){
  151.     Building::print();
  152.    
  153. cout << "Number of rooms per level are : " << noOfroomPlevel << endl;
  154. cout << "Number of available rooms are : " << noOfAvaRoom << endl;
  155. cout<<"----------------------- \n";
  156. rest.printMenu();
  157. }
  158.  
  159. Hotel::Hotel(string a, string b, int c):Building(a,b,c),rest(a,b,c){
  160.     noOfroomPlevel = noOfAvaRoom = 0;
  161. }
  162.  
  163. Hotel::~Hotel(){
  164. cout <<  "This is the Hotel Destructor" << endl;
  165. }
  166. int main(){
  167.    
  168.     Hotel h("Mareot", "Amman", 15);
  169.     h.setAll(9,20);
  170.     h.print();
  171.     cout<<"----------------------- \n";
  172.     h.MakeDelivery();
  173.     cout<<"----------------------- \n";
  174.     h.DeleteDelivery(3);
  175.  
  176. return 0;
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement