Question

In C++.

Suppose a restaurant hired you to digitalize all their servers pads (for taking orders... see picture below). Make a class t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Pad class ScreenShot:

class Pad{ // --- Making All fields (instance variables & functions ) public ---- // public: // === All required instance var

Program code to copy:

#include <iostream>
using namespace std;

// --- Making a 'Pad' class

class Pad{
  
   // --- Making All fields (instance variables & functions ) public ---- //
  
   public:
      
       // === All required instance variables
      
       /*
           Since we have to store multiple orders of a customer. So we will use arrays in which
           we will store multiple items, their special instructions & quantity of menu items ordered
           we will dynamically allocate arrays in the constructors
       */
      
       string *menuItemsOrdered;       // (**) _The menu items which is ordered by customer
      
       string *specialInstruction;   // (**) _It will specify special instructions as mentioned __ i.e. no onions
      
       int *quantity;               // (**) _The quantity of that menu item which is ordered
      
       // ==== The constructors as specified in statement, just declaration of these functions
      
       // (**) _A default constructor
  
       Pad();
      
       // (**) _A parameterizd constructor that takes in the first menu Item ordered
      
       Pad(string firstItemOrdered);
};

*********** DO NOT COPY BELOW CODE, IT IS JUST FOR TESTING **********

/*   -----------------------------------------------------------------------------------------
   --------------- Just for Testing our class works correct or not --------------
   -------------------------------------------------------------------------------------------
*/

Pad::Pad(){
   // --- Suppose maximum ten items customer can order
  
   menuItemsOrdered = new string[10];
   specialInstruction = new string[10];
   quantity = new int[10];
}

Pad::Pad(string firstItemOrdered){
  
   // --- Allocating arrays dynamically
  
   menuItemsOrdered = new string[10];
   specialInstruction = new string[10];
   quantity = new int[10];
  
   // --- Assigning first item in ordered to the first index of the array (menuItemsOrdered) as specified
  
   menuItemsOrdered[0] = firstItemOrdered;
}

int main(){
  
   // --- Test code to test the Pad class
   // --- Lets order 2 items i.e. Pizza & Burger
  
   Pad *pad = new Pad("Pizza");
   pad->specialInstruction[0] = "More Spicy & Baked";
   pad->quantity[0] = 2;
  
   pad->menuItemsOrdered[1] = "Zinger Burger";
   pad->specialInstruction[1] = "More Crispy";
   pad->quantity[1] = 3;
  
   // --- Lets print items whether class works exactly as specified or not
  
   cout << endl << "Menu Items:" << endl;
   cout << "---------------------------------" << endl;

   for(int i=0; i<2; i++){
      
       cout << "Item no." << i+1 << endl;
       cout << "Name: " << pad->menuItemsOrdered[i] << endl;
       cout << "Special Instruction: " << pad->specialInstruction[i] << endl;
       cout << "Quantity: " << pad->quantity[i] << endl;
       cout << "---------------------------------" << endl;
   }
  
   return 0;
}

Sample output:

Menu Items: Item no.1 Name: Pizza Special Instruction: More Spicy & Baked Quantity: 2 Item no.2 Name: Zinger Burger Special I

-------------------------------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERIES...............................
HIT A THUMBS UP IF YOU DO LIKE IT!!!

Add a comment
Know the answer?
Add Answer to:
In C++. Suppose a restaurant hired you to digitalize all their servers' pads (for taking orders......
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT