Question: Need some Help for C++ My Timer or clock is suppose to display well i timed session with random moments of a guest arriving but

Need some Help for C++ My Timer or clock is suppose to display well i timed session with random moments of a guest arriving but its not i just get " Press any Key to contiune" Nothing else is displayed below is the code both cpp and header files are there Thank you for the Help.

thnx for any help all help

Header filles

#pragma once

//Headers

//system

#include

#include

#include

using namespace std;

class Customer

{

public:

int gstWaitTime;//Guest Wait Time,

int serviceTime;// Servers service Time

int orderCounter;// Count the Orders

int serviceCount; // The Restaurant Service Counter

int guestOrderTime;// Guest ORDER TIME!!!

int test;// Testing

Customer *nextGuest;

Customer();

~Customer();

private:

};

#pragma once

#include"Customer.h"

#include"TimeClock.h"

//system

#include

#include

#include

using namespace std;

class Queue

{

public:

void incrGstWaitTime();

void displayContents();

void newCustomer(int g);

void removeCustomer();

void checkStatus();

Customer* top;

Customer* bottom;

int totalGstWaitTime;// Total Wait Time for Guest

int totalAmountCustomers;// Total Customers restaurant

Queue();

~Queue();

private:

};

#pragma once

//

#include"Queue.h"

#include"Customer.h"

//

#include

#include

#include

using namespace std;

class TimeClock

{

public:

int Clock = 1;

int totalAmountCustomers = 0;

float guestArrival = 0;

int num;// NUMBER

int guestOrderTime; // Order Time

float totalGstWaitTime; //Total Wait Time

float totalServiceTime; //Total Service Time

TimeClock();

~TimeClock();

private:

};

.cpp files

#include"Customer.h"

#include"Queue.h"

//

#include

#include

#include

using namespace std;

Customer::Customer()

{

test = 0;

orderCounter = 0;

gstWaitTime = 0;

serviceTime = 0;

guestOrderTime = 0;

nextGuest = NULL;

}

Customer::~Customer()

{

}

#include"Queue.h"

//#include"Customer.h"

#include"TimeClock.h"

//

#include

#include

#include

using namespace std;

Queue::Queue()

{

bottom = NULL;

top = NULL;

totalGstWaitTime = 0;

totalAmountCustomers = 0;

}

void Queue::incrGstWaitTime()

{

Customer *temp;

temp = top;

if (top == NULL)

{

return;

}

else

{

if (temp->nextGuest == bottom)

{

temp->gstWaitTime++;

}

else

{

while (temp->nextGuest != NULL && temp->nextGuest != bottom)

{

temp->gstWaitTime = temp->gstWaitTime + 1;

temp = temp->nextGuest;

}

}

}

}

void Queue::displayContents()

{

Customer *temp;

temp = top;

while (temp != NULL)

{

cout << temp->test << "---->";

temp = temp->nextGuest;

}

cout << endl;

}

void Queue::newCustomer(int g)

{

Customer *temp = new Customer;

temp->guestOrderTime = g;

if (top == NULL)

{ //No customers in line

top = bottom = temp;

totalAmountCustomers++;

cout << "There is a new customer." << endl;

}

else

{

temp->nextGuest = top;

top = temp;

totalAmountCustomers++;

cout << "There is a new customer." << endl;

}

}

void Queue::removeCustomer()

{

Customer *chase, *follow;

chase = follow = top;

if (top == NULL)

{

//No customers in queue.

cout << "No customers are in line.. there's nothing to remove." << endl;

return;

}

else

{

if (top->nextGuest == NULL)

{

//Only one customer

delete top;

top = NULL;

bottom = NULL;

return;

}

while (chase->nextGuest != NULL)

{

follow = chase;

chase = chase->nextGuest;

}

delete chase;

bottom = follow;

follow->nextGuest = NULL;

}

}

void Queue::checkStatus()

{

if (top == NULL)

{

bottom = NULL;

return;

}

else if (bottom->orderCounter != bottom->guestOrderTime)

{

bottom->orderCounter++;

bottom->gstWaitTime++;

}

else

{

totalGstWaitTime = totalGstWaitTime + bottom->gstWaitTime;

removeCustomer();

}

}

Queue::~Queue()

{

}

#include"TimeClock.h"

#include"Queue.h"

#include"Customer.h"

//

#include

#include

#include

using namespace std;

TimeClock::TimeClock()

{

Queue Restaurant;

srand(time(NULL));

while (Clock < 1140)

{

while (Clock < 120)

{

num = rand();

num = num % 10 + 1; //Generates a number between 1 and 10

if (num >= 1 && num <= 3)

{

guestOrderTime = rand();

guestOrderTime = guestOrderTime % 6 + 1; //Creates orderTime between 1 and 6

Restaurant.newCustomer(guestOrderTime);

cout << "Timed Mark: " << Clock << " minutes." << endl;

Clock++;

}

else

{

Restaurant.checkStatus();

Restaurant.incrGstWaitTime();

cout << "The Timer has reach/past: " << Clock << " minutes." << endl;

Clock++;

}

}

Clock = 1140;

}

cout << "There were " << Restaurant.totalAmountCustomers << " customers. " << endl;

cout << "Average Time a Customer's has waited is around: "

<< Restaurant.totalGstWaitTime / Restaurant.totalAmountCustomers << " minutes per customer." << endl;

}

TimeClock::~TimeClock()

{

}

//System

#include

#include

#include

using namespace std;

//Header

#include"Customer.h"

#include"Queue.h"

#include"TimeClock.h"

int main()

{

Queue Restaurant();

system("pause");

return 1;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!