Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So I have No clue were my problem is in my c++ coding I have gone line by line a

ID: 3707537 • Letter: S

Question

So I have No clue were my problem is in my c++ coding I have gone line by line and I cant seem to find out why I am not getting my clock to display at all Can someone help me on it Below is my code both cpp and header files thank you very much for the help.

Header filles

#pragma once

//Headers

//system

#include<iostream>

#include <time.h>

#include <stdlib.h>

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 <iostream>

#include <time.h>

#include <stdlib.h>

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 <iostream>

#include <time.h>

#include <stdlib.h>

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<iostream>

#include <time.h>

#include <stdlib.h>

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 <iostream>

#include <time.h>

#include <stdlib.h>

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 <iostream>

#include <time.h>

#include <stdlib.h>

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<iostream>

#include <time.h>

#include <stdlib.h>

using namespace std;

//Header

#include"Customer.h"

#include"Queue.h"

#include"TimeClock.h"

int main()

{

       Queue Restaurant();

       system("pause");

       return 0;

}

Explanation / Answer

#include<iostream>

#include <time.h>

#include <stdlib.h>

using namespace std;

class Customer

{

public:

       int gstWaitTime;

       int serviceTime;

       int orderCounter;

       int serviceCount;

       int guestOrderTime;

       int test;

       Customer *nextGuest;

       Customer();

       ~Customer();

private:

};

#pragma once

#include"Customer.h"

#include"TimeClock.h"

//system

#include <iostream>

#include <time.h>

#include <stdlib.h>

using namespace std;

class Queue

{

public:

       void incrGstWaitTime();

       void displayContents();

       void newCustomer(int g);

       void removeCustomer();

       void checkStatus();

       Customer* top;

       Customer* bottom;

       int totalGstWaitTime;

       int totalAmountCustomers;

       Queue();

       ~Queue();

private:

};

#pragma once

//

#include"Queue.h"

#include"Customer.h"

//

#include <iostream>

#include <time.h>

#include <stdlib.h>

using namespace std;

class TimeClock

{

public:

       int Clock = 1;

       int totalAmountCustomers = 0;

       float guestArrival = 0;

       int num;// NUMBER

       int guestOrderTime;

       float totalGstWaitTime;   

       float totalServiceTime;

       TimeClock();

       ~TimeClock();

private:

};

.cpp files

#include"Customer.h"

#include"Queue.h"

//

#include<iostream>

#include <time.h>

#include <stdlib.h>

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 <iostream>

#include <time.h>

#include <stdlib.h>

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 <iostream>

#include <time.h>

#include <stdlib.h>

using namespace std;

TimeClock::TimeClock()

{

       Queue Restaurant;

     

       srand(time(NULL));

       while (Clock < 1140)

       {

              while (Clock < 120)

              {

                     num = rand();

                     num = num % 10 + 1;

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

                     {

                           guestOrderTime = rand();

                           guestOrderTime = guestOrderTime % 6 + 1;                           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()

{

}

#include<iostream>

#include <time.h>

#include <stdlib.h>

using namespace std;

#include"Customer.h"

#include"Queue.h"

#include"TimeClock.h"

int main()

{

       Queue Restaurant();

       system("pause");

       return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote