Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ * Program name: jbtictactoe.cpp * Author: John Doe * Date last updated: 5 / 1 / 2 0 1 7 * Purpose: Play the

/* Program name: jbtictactoe.cpp
* Author: John Doe
* Date last updated: 5/1/2017
* Purpose: Play the game of Tic-Tac-Toe
*/
#include
#include
#include
using namespace std;
// Struct to manage a reservation
struct Reservation {
string customerName;
int numberOfPeople;
string reservationTime;
bool isCheckedIn;
};
// Struct to manage a table
struct Table {
int tableNumber;
int capacity;
int currentOccupancy;
bool isFree;
};
// Enumeration to manage the menu items
enum MenuItem {
VEGGIE_BURGER =0,
HAMBURGER,
FRIED_CHICKEN_SLIDERS,
HAMBURGER_SLIDERS,
VEGGIE_SLIDERS,
HADDOCK_SANDWICH,
BLT,
FAUX_BLT,
CHICKEN_BURRITO,
FALAFEL_WRAP,
CHEESE_PIZZA,
PEPPERONI_PIZZA,
FAUX_MEAT_AND_CHIPS,
FISH_AND_CHIPS,
NUM_ITEMS
};
// Struct to manage an order
struct Order {
Reservation reservation;
Table table;
MenuItem itemsOrdered[10];
int numberOfItems;
bool isComplete;
bool isPaid;
};
// Arrays to manage tables, reservations, and orders
Table tables[20]={{1,2,0, true},{2,2,0, true},{3,4,0, true},{4,6,0, true},
{5,6,0, true},{6,6,0, true},{7,6,0, true},{8,6,0, true},
{9,10,0, true},{10,10,0, true},{11,10,0, true},{12,10,0, true},
{13,10,0, true},{14,10,0, true},{15,10,0, true},{16,10,0, true},
{17,10,0, true},{18,10,0, true},{19,10,0, true},{20,10,0, true}};
Reservation reservations[50];
Order orders[50];
// Function to make a reservation
void makeReservation(){
// Find an empty slot in the reservations array
int emptySlot =-1;
for (int i =0; i <50; ++i){
if (reservations[i].customerName.empty()){
emptySlot = i;
break;
}
}
// If there's no empty slot, inform the user and return
if (emptySlot ==-1){
cout << "Sorry, the restaurant cannot accept more reservations at the moment.
";
return;
}
// Otherwise, proceed with making the reservation
cout << "Enter a name for the reservation: ";
cin.ignore(); // Ignore the newline character left in the buffer
getline(cin, reservations[emptySlot].customerName);
cout << "Enter the number of people in the party: ";
cin >> reservations[emptySlot].numberOfPeople;
string party;
getline(cin,party);
cout << "Enter the time for the reservation in HH::MM AM/PM: ";
getline(cin, reservations[emptySlot].reservationTime);
reservations[emptySlot].isCheckedIn = false;
cout << "Please confirm the reservation:
";
cout << "Reservation Name: "<> reservationIndex;
reservationIndex--; // Adjust for array index
// Check if the reservation number is valid
if (reservationIndex <0|| reservationIndex >=50|| reservations[reservationIndex].customerName.empty()|| reservations[reservationIndex].isCheckedIn){
cout << "Invalid reservation number or already checked in.
";
return;
}
// Find a suitable table for the reservation
Table* suitableTable = null

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago

Question

Describe the job youd like to be doing five years from now.

Answered: 1 week ago

Question

So what disadvantages have you witnessed? (specific)

Answered: 1 week ago