ASSIGNMENT 13
#include <iostream>
using namespace std;
#define SIZE 5
// Struct to represent the pizza queue
struct PizzaQueue {
int orders[SIZE];
int front;
int rear;
};
// Function to initialize the queue
void initializeQueue(PizzaQueue &pq) {
[Link] = -1;
[Link] = -1;
// Function to check if the queue is full
bool isFull(PizzaQueue &pq) {
return (([Link] == 0 && [Link] == SIZE - 1) || ([Link] == [Link] + 1));
// Function to check if the queue is empty
bool isEmpty(PizzaQueue &pq) {
return ([Link] == -1);
// Function to accept a new order
void acceptOrder(PizzaQueue &pq, int order) {
if (isFull(pq)) {
cout << "Sorry, the queue is full!" << endl;
return;
if (isEmpty(pq)) { // If the queue is empty, initialize front and rear
[Link] = 0;
[Link] = 0;
} else { // Increment rear in a circular manner
[Link] = ([Link] + 1) % SIZE;
[Link][[Link]] = order;
cout << "Order accepted: Pizza type " << order << endl;
// Function to deliver orders
void deliverOrders(PizzaQueue &pq, int numOrders) {
if (isEmpty(pq)) {
cout << "No pending orders!" << endl;
return;
cout << "Delivering the following orders: " << endl;
for (int i = 0; i < numOrders; i++) {
if (isEmpty(pq)) {
cout << "\nNo more orders to deliver!" << endl;
break;
}
int deliveredOrder = [Link][[Link]];
cout << "Pizza type " << deliveredOrder << endl;
// Remove the delivered order from the queue
if ([Link] == [Link]) { // If there's only one order
[Link] = -1;
[Link] = -1;
} else { // Increment front in a circular manner
[Link] = ([Link] + 1) % SIZE;
cout << "Total amount to pay: " << numOrders * 100 << " units" << endl;
// Function to display pending orders
void displayOrders(PizzaQueue &pq) {
if (isEmpty(pq)) {
cout << "No pending orders!" << endl;
return;
cout << "Pending orders: ";
int temp = [Link];
while (true) {
cout << [Link][temp] << " ";
if (temp == [Link]) {
break;
temp = (temp + 1) % SIZE;
cout << endl;
}
int main() {
PizzaQueue pq;
initializeQueue(pq);
int choice, pizzaType, numOrders;
do {
cout << "\n\n______Welcome To MMCOE Pizza house______" << endl;
cout << "1. Accept Order" << endl;
cout << "2. Deliver Orders" << endl;
cout << "3. Display Pending Orders" << endl;
cout << "4. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
cout << "\n____MENU___" << endl;
cout << "[Link] Pizza" << endl;
cout << "2. golden corn Pizza" << endl;
cout << "[Link] Pizza" << endl;
cout << "Which pizza do you want? Enter the respective number: ";
cin >> pizzaType;
acceptOrder(pq, pizzaType);
break;
case 2:
cout << "\nHow many pizzas do you want to deliver? ";
cin >> numOrders;
deliverOrders(pq, numOrders);
break;
case 3:
displayOrders(pq);
break;
case 4:
cout << "Exiting the program. Thank you for visiting!" << endl;
break;
default:
cout << "Invalid choice, please try again!" << endl;
} while (choice != 4);
return 0;}