Answered step by step
Verified Expert Solution
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:
Purpose: Play the game of TicTacToe
#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
VEGGIEBURGER
HAMBURGER,
FRIEDCHICKENSLIDERS,
HAMBURGERSLIDERS,
VEGGIESLIDERS,
HADDOCKSANDWICH,
BLT
FAUXBLT
CHICKENBURRITO,
FALAFELWRAP,
CHEESEPIZZA,
PEPPERONIPIZZA,
FAUXMEATANDCHIPS,
FISHANDCHIPS,
NUMITEMS
;
Struct to manage an order
struct Order
Reservation reservation;
Table table;
MenuItem itemsOrdered;
int numberOfItems;
bool isComplete;
bool isPaid;
;
Arrays to manage tables, reservations, and orders
Table tables true true true true
true true true true
true true true true
true true true true
true true true true;
Reservation reservations;
Order orders;
Function to make a reservation
void makeReservation
Find an empty slot in the reservations array
int emptySlot ;
for int i ; i ; i
if reservationsicustomerName.empty
emptySlot i;
break;
If there's no empty slot, inform the user and return
if emptySlot
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
getlinecin reservationsemptySlotcustomerName;
cout "Enter the number of people in the party: ;
cin reservationsemptySlotnumberOfPeople;
string party;
getlinecinparty;
cout "Enter the time for the reservation in HH::MM AMPM: ;
getlinecin reservationsemptySlotreservationTime;
reservationsemptySlotisCheckedIn false;
cout "Please confirm the reservation:
;
cout "Reservation Name: reservationIndex;
reservationIndex; Adjust for array index
Check if the reservation number is valid
if reservationIndex reservationIndex reservationsreservationIndexcustomerName.empty reservationsreservationIndexisCheckedIn
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started