Monday, April 13, 2015

 
#include
#include
#include

using namespace std;

  //**************** customerType  ****************

class customerType
{
public:
    customerType(int cN = 0, int arrvTime = 0, int wTime = 0,
        int tTime = 0);
 //Constructor to initialize the data members
 //according to the parameters
 //In the object declaration if no value is specified,
 //the default is assigned.
 //Postcondition: customerNumber = cN;
 //           arrivalTime.clock = arrvTime;
 //               waitingTime.clock = wTime;
 //           transactionTime.clock = tTime;

    void setCustomerInfo(int customerN = 0, int inTime = 0,
int wTime = 0, int tTime = 0);
 //Data members are set according to the parameters
 //Postcondition: customerNumber = customerN;
 //           arrivalTime.clock = arrvTime;
 //               waitingTime.clock = wTime;
 //           transactionTime.clock = tTime;

    int getWaitingTime() const;
 //Returns the value of waitingTime.

    void setWaitingTime(int time);
 //The waiting time is set according to the parameter
 //Postcondition: waitingTime = time;

    void incrementWaitingTime();
 //Value of waitingTime is incremented by one clock unit.
 //Postcondition: waitingTime++;

    int getArrivalTime();
 //Returns the value of arrivalTime.

    int getTransactionTime();
 //Returns the value of transactionTime.

    int getCustomerNumber();
 //Returns the value of customerNumber.
private:
    int customerNumber;
int arrivalTime;
int waitingTime;
int transactionTime;
};



//*************  serverType  ****************

class serverType
{
public:
    serverType();
 //Default constructor
 //Sets the value of the data member to their
 //default values
 //Postcondition: currentCustomer is initialized by its
 //               default constructor
 //               status = "free"
 //               transaction time is initialized to 0

    bool isFree() const;
 //Returns true if the server is free; false otherwise

    void setBusy();
 //Set the status of the server to busy
 //Postcondition: status = "busy";

    void setFree();
 //Set the status of the server to Free
 //Postcondition: status = "free";

    void setTransactionTime(int t);
 //Set the transaction time according to the parameter t
 //Postcondition: transactionTime = t;

    void setTransactionTime();
 //Set the transaction time according to the transaction
 //time of the current customer's transaction time
 //Postcondition: transactionTime = currentCustomer.transactionTime;

    int getRemainingTransactionTime();
 //Returns the remaining transaction time.
 //The value of transactionTime is returned

    void decreaseTransactionTime();
 //Decrease the transactionTime by 1
 //Postcondition: transactionTime--;

    void setCurrentCustomer(customerType cCustomer);
 //Set the info of the current customer according to the
 //parameter cCustomer
 //Postcondition: currentCustomer = cCustomer;

    int getCurrentCustomerNumber();
 //Returns the customer number of the current customer

    int getCurrentCustomerArrivalTime();
 //Return the arrival time of the current customer
 //The value of the data member arrivalTime of
 //currentCustomer is returned

    int getCurrentCustomerWaitingTime();
 //Returns the current waiting time of the current customer
 //The value of transactionTime is returned

    int getCurrentCustomerTransactionTime();
 //Returns the current customer's transaction time

private:
    customerType currentCustomer;
    string status;
    int transactionTime;
};


class serverListType
{
public:
   serverListType(int num = 1);
      //constructor to initialize a list of servers
      //Postcondition: numOfServers = num
      //     A list of servers, specified by num, is
      //     created and each server is initialized to free.

   ~serverListType();
      //Destructor
      //Postcondition: The list of servers is destroyed

   int getFreeServerID();
      //Search the list of servers.
      //If a free server is found, return its ID;
      //otherwise, return -1.

   int getNumberOfBusyServers();
      //Returns the number of busy servers

   void setServerBusy(int serverID, customerType cCustomer,
 int tTime);
      //Set the server specified by serverID to busy
      //to serve the customer specified by cCustomer
      //transaction time is set to according to the
      //parameter tTime.

   void setServerBusy(int serverID, customerType cCustomer);
      //Set the server specified by serverID to busy
      //to serve the customer specified by cCustomer
      //transaction time is set according to
      //the transaction time of the customer.

   void updateServers();
      //The transaction time of each busy server is decremented
      //by one unit. If the transaction time of a busy server
      //is reduced to zero, the server is set to free and a
      //message indicating which customer is served, together
      //with the customer's departing time, is printed on
      //the screen.

   void updateServers(ofstream& outFile);
      //The transaction time of each busy server is decremented
      //by one unit. If the transaction time of a busy server
      //is reduced to zero, the server is set to free and a
      //message indicating which customer is served, together
      //with the customer's departing time, is sent to a file.

private:
    int numOfServers;
    serverType *servers;
};

No comments: