Working on a simulation which closely resembles waiting in a line at a bank. Program runs the simulation based on the user's inputs of # of servers, simulation time, average time between arrival, and transaction time. Here's what I have so far:

/*~~~prog3.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |                                                                     |
 |                                                                     |
 |  Author: Megan MacDonald                                            |
 |  Date Completed: April 3, 2009                                      |
 |  Class: CSC 2110, section 002                                       |
 |  Tennessee Technological University                                 |
 |                                                                     |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
#include <string>

using namespace std;

#include "Control.h"
#include "server.h"
#include "Queue_of_Jobs.h"

#define Max_Server 10
#define Min_Server 0
#define Max_simTime 10000
#define Min_simTime 0
#define Max_transTime 100
#define Min_transTime 0
#define Max_arrivalTime 100
#define Min_arrivalTime 0

int main()
{
	int servers, simTime, transTime, arrivalTime;
	//get parameters
	cout<<"Number of Servers? ";
	cin>>servers;
	cout << endl;
	
	while (servers > Max_Server || servers < Min_Server)
	{
		cout << "The number of servers you entered is outside of scope. " << endl
			 << "Please enter a number between 0 & 10: ";
		cin >> servers;
		cout << endl;
	}
	
	cout<<"Simulation Time? ";
	cin>>simTime;
	cout << endl;
	
	while (simTime > Max_simTime || simTime < Min_simTime)
	{
		cout << "The simulation time you entered is outside of scope. " << endl
			 << "Please enter a number between 0 & 10000: ";
		cin >> simTime;
		cout << endl;
	}
	
	cout<<"Transition Time? ";
	cin>>transTime;
	cout << endl;
	
	while (transTime > Max_transTime || transTime < Min_transTime)
	{
		cout << "The transaction time you entered is  outside of scope. " << endl
			 << "Please enter a number between 0 & 100: ";
		cin >> transTime;
		cout << endl;
	}
	
	cout<<"Arrival Time? ";
	cin>>arrivalTime;
	cout << endl;
	
	while (arrivalTime > Max_arrivalTime || arrivalTime < Min_arrivalTime)
	{
		cout << "The arrival time you entered is outside of scope. " << endl
			 <<"Please enter a number between 0 & 100: ";
		cin >> arrivalTime;
		cout << endl;
	}
	
	cout<<servers<<endl;
	cout<<simTime<<endl;
	cout<<transTime<<endl;
	cout<<arrivalTime<<endl;
	
	Control c;
	Server s;
	Queue_of_Jobs q;
	Job temp;
	
	int clock;
	int t;       //used for random number
	int tempTime; //used for time of customer in front
	int waitTime; //used to calculate the job's wait time
	
	s.insert(servers);
	s.display();
	
	cout << endl << endl;
	
	for (clock=0; clock<simTime; clock++)
	{
		t=rand()%5;
		if(q.checkForNewJob(t))
		{
			temp.inTime = clock;
			q.enqueue(temp);
			cout << "Customer enqueued" << endl;
		}
		else
			cout << "Customer did not arrive" << endl;
		if (q.checkLine())
			cout << "There is a customer waiting in line" << endl;
		int tempFront=q.front();
		if (q.dequeue())
		{
			waitTime = clock - tempFront;
			cout << "Wait Time of Customer is: " << waitTime << endl;
			cout << "~~~~~A Customer was DeQueued~~~" << endl;
		}
		c.totalWait(waitTime);
		//check servers
		//update servers
		cout << "*************************************" << endl;
	}
}
/*~~~server.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |                                                              |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
#include <string>
using namespace std;
typedef int ServerType;
class Server
	{
	private:
		int mySize;
		class Node
		{
		public:
			int data;
			Node * next;
			Node(int ident){
				data = ident;
				next = NULL;
			}
		};
		typedef Node * NodePointer;
		NodePointer first;
	public:
		Server();
		bool isAvailable();
		void engage();
		void disEngage();
		void insert(int numServers);
		void display();
	};
/*~~~server.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |                                                              |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
using namespace std;
#include "server.h"

Server::Server()
{
	first = NULL;
	mySize = 0;
}

bool Server::isAvailable()
{
	
}

void Server::engage()
{
	
}

void Server::disEngage()
{
	
}

void Server::insert(int numServers)
{
	cout << "MySize: " << mySize << endl;
	int index;
	int i;
	for (index=0; index<numServers; index++)
	{
		NodePointer nPtr = new Node(index);
		if (index == 0)
		{
			nPtr->next = first;
			first = nPtr;
		}
		else
		{
			NodePointer predPtr = first;
			for (i=0; i==mySize; i++)
			{
				predPtr = predPtr->next;
			}
			nPtr->next = predPtr->next;
			predPtr->next = nPtr;
		}
		mySize++;
	}
	cout << "MySize: " << mySize << endl;
}

void Server::display()
{
	NodePointer ptr;
	ptr = first;
	while (ptr != NULL)
	{
		cout << ptr->data;
		ptr = ptr->next;
	}
	
}
/*~~~Queue_of_Jobs.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |                                                              |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
#include <string>
using namespace std;
typedef struct Job ElementType;

#define capacity 100

struct Job
{
	int inTime;
};

class Queue_of_Jobs
	{
	private:
		ElementType myArray[capacity];
		int mySize;
		int frontOfQueue;
		int back;
		int count;
	public:
		Queue_of_Jobs();
		bool enqueue(ElementType newJob);
		bool dequeue();
		int front();
		int size();
		bool checkForNewJob(int number);
		bool checkLine();
	};
/*~~~job.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |                                                               |
 |                                                               |
 |  Author: Megan MacDonald                                      |
 |  Date Completed: April 3, 2009                                |
 |  Class: CSC 2110, section 002                                 |
 |  Tennessee Technological University                           |
 |                                                               |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
#include <ctime>
#include <cstdlib>
#include "Queue_of_Jobs.h"

Queue_of_Jobs::Queue_of_Jobs()
{
	mySize = 0;
	frontOfQueue = 0;
	back = 0;
	count = 0;
}

bool Queue_of_Jobs::enqueue(ElementType newJob)
{
	if (mySize == capacity)
	{
		cout << "Queue if full." << endl;
		return false;
	}
	else
	{
		myArray[back] = newJob;
		back = (back + 1)%capacity;
		count++;
		mySize++;
		return true;
	}
}

bool Queue_of_Jobs::dequeue()
{
	if (front() == 0) //Queue is empty
	{
		cout << "Queue was empty - could not remove a customer." << endl;
		return false;
	}
	else
	{
		ElementType j = myArray[frontOfQueue];
		if (frontOfQueue == capacity)
		{
			frontOfQueue = 0;
		}
		frontOfQueue = frontOfQueue + 1;
		count--;
		mySize--;
		cout << "Front of queue: " << frontOfQueue << endl;
		return true;
	}
}

int Queue_of_Jobs::front()
{
	if (checkLine())
	{
		ElementType j = myArray[frontOfQueue];
		return (j.inTime);
	}
	else
	{
		//Queue is empty
		return 0;
	}
}

int Queue_of_Jobs::size()
{
	mySize = (back - frontOfQueue)%capacity;
	return mySize;
}

bool Queue_of_Jobs::checkForNewJob(int number)
{
	if (number%2)
		return true;
	else
		return false;
}

bool Queue_of_Jobs::checkLine()
{
	if (count >= 1)
		return true;
	else
		return false;
}
/*~~~Control.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |                                                               |
 |                                                               |
 |  Author: Megan MacDonald                                      |
 |  Date Completed: April 3, 2009                                |
 |  Class: CSC 2110, section 002                                 |
 |  Tennessee Technological University                           |
 |                                                               |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>

class Control
	{
	private:
		int averageWaitTime;
		int totalWaitTime;
	public:
		Control();
		int totalWait(int waittime);
		int averageWait(int numJobs);
		void display();
	};
/*~~~Control.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |                                                              |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
using namespace std;
#include "Control.h"

Control::Control()
{
	totalWaitTime = 0;
	averageWaitTime = 0;
}

int Control::totalWait(int waittime)
{
	totalWaitTime = totalWaitTime + waittime;
}

int Control::averageWait(int numJobs)
{
	averageWaitTime = totalWaitTime / numJobs;
}

void Control::display()
{
	cout << "Total Wait Time: " << totalWaitTime << endl;
	cout << "Average Wait Time was: " << averageWaitTime << endl;
}

1. Please, use code tag correctly:
[code=cplusplus] sources

[/code]
2. Is it a question?.. or presentation? ;)

I'm not sure what you are looking for but the structure looks good. I didn't analyze it but it *looks* well written, which I have to say is quite refreshing to see.

ArkM: Thanks for the tip on inserting the code -- didn't realize there was a difference.
Also, this is a presentation, rather a work in progress: I felt like sharing:icon_cool:
And thanks Adam

Just one thing; shouldn't the last file's header docs be control.cpp? not control.h

You have two control.h's

Ok here's the finished program :)

/*~~~prog3.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |  "Waiting ...waiting... Next!"                                      |
 |  Program 3: A Queuing Simulation                                    |
 |                                                                     |
 |  This program creates a simulation similar to that of a bank line.  |
 |		The program starts by receiving the user's input data for the  |
 |		number of server, the simulation time, the transaction time,   |
 |		and the average arrival time. Then the program checks to make  |
 |		sure the data is within the scope.                             |
 |	Once data is within scope, program commences. The servers are      |
 |		inserted and the transaction_time is initialized.              |
 |	Then the main loop of the simulation commences: the clock is used  |
 |		as an incrementor and when clock reaces simulation time,       |
 |		simulation ends.                                               |
 |	First, the simulation checks for a new customer. If there is one,  |
 |		the job is enqueued with the current clock as its input value. |
 |      The number of jobs enqueued is incremented.                    |
 |	Next, the program checks the line for any jobs as a test.          |
 |  Then, the program runs through the servers. First, if a server is  |
 |		available and there is someone in line, a job gets dequeued.   |
 |      Then the wait time for that job is computed and added to the   |
 |      total wait time and that server is engaged.                    |
 |	Another for loop checks the servers for if they are not available. |
 |		If they aren't available, their transaction time is            |
 |		incremented.												   |
 |	Then, the servers are check to see if they have reached the        |
 |		transaction_time, and if they have they are disEngaged.	       |
 |	Outside of the clock/simulation loop, the number of jobs left in   |
 |		the queue are calculated, along with how long those in the	   |
 |		queue have waited thus far.                                    |
 |	Finally, the number of jobs left, their wait time, the total wait  |
 |		time, and the average wait time per job is displayed.          |
 |                                                                     |
 |  Author: Megan MacDonald                                            |
 |  Date Completed: April 3, 2009                                      |
 |  Class: CSC 2110, section 002                                       |
 |  Tennessee Technological University                                 |
 |                                                                     |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
#include <string>

using namespace std;

#include "Control.h"
#include "server.h"
#include "Queue_of_Jobs.h"

#define Max_Server 10  //sets the define statements...
#define Min_Server 0
#define Max_simTime 10000
#define Min_simTime 0
#define Max_transTime 100
#define Min_transTime 0
#define Max_arrivalTime 100
#define Min_arrivalTime 0

int main()
{
	Control c;        //creating objects...
	Server s;
	Queue_of_Jobs q;
	Job temp;
	
	int clock;       //used for running simulation
	int i;           //used in for loop
	int t;       //used for random number
	int tempTime; //used for time of customer in front
	int waitTime; //used to calculate the job's wait time
	int servers, simTime, transTime, arrivalTime;  //declares input variables
	int numberOfJobsEnqueued = 0;
	int numberOfJobsDequeued = 0;
	
	cout<<"Number of Servers? ";
	cin>>servers;      //sets the servers to the user's input
	cout << endl;
	
	while (servers > Max_Server || servers < Min_Server)  //checks to make sure value is w/in scope
	{
		cout << "The number of servers you entered is outside of scope. " << endl
			 << "Please enter a number between 0 & 10: ";
		cin >> servers;
		cout << endl;
	}
	
	cout<<"Simulation Time? ";
	cin>>simTime;      //sets the simulation time to the user's input
	cout << endl;
	
	while (simTime > Max_simTime || simTime < Min_simTime)  //checks to make sure value is w/in scope
	{
		cout << "The simulation time you entered is outside of scope. " << endl
			 << "Please enter a number between 0 & 10000: ";
		cin >> simTime;
		cout << endl;
	}
	
	cout<<"Transaction Time? ";
	cin>>transTime;     //sets the transaction time to the user's input
	cout << endl;
	
	while (transTime > Max_transTime || transTime < Min_transTime)  //checks to make sure value is w/in scope
	{
		cout << "The transaction time you entered is  outside of scope. " << endl
			 << "Please enter a number between 0 & 100: ";
		cin >> transTime;
		cout << endl;
	}
	
	cout<<"Arrival Time? ";
	cin>>arrivalTime;   //sets the average arrival time to the user's input
	cout << endl;
	
	while (arrivalTime > Max_arrivalTime || arrivalTime < Min_arrivalTime)  //checks to make sure value is w/in scope
	{
		cout << "The arrival time you entered is outside of scope. " << endl
			 <<"Please enter a number between 0 & 100: ";
		cin >> arrivalTime;
		cout << endl;
	}
	
	s.setTransaction(transTime);     //setting the transaction_time...
	s.insert(servers);               //creating the servers...
	cout << "Display: " << endl;
	s.display();                     //displays the server list...
	
	cout << endl << endl;
	
	/*Time simulation using the user's input for simulation
	length and incrementing the clock until it reaches
	the simulation time.*/
	for (clock=0; clock<simTime; clock++)
	{
		t=rand()%arrivalTime;     //random number generator bbased on average arival time
		if(q.checkForNewJob(t))   //checks for a job based on the random number
		{
			temp.inTime = clock;  //sets the in time to the clock
			q.enqueue(temp);      //enqueue the clock's time
			numberOfJobsEnqueued++;
			cout << "Customer Arrived" << endl;
		}
		else
			cout << "Customer did not arrive" << endl;
		if (q.checkLine())        //checks to see if there is anyone waiting
			cout << "There is a customer waiting in line" << endl;
		int tempFront=q.front();  //temporary storage for the value at front of the queue
		for (i=0; i<servers; i++) //for loop runs from 0 to number of servers
		{
			if (s.isAvailable(i) && q.checkLine())    //if a server is available and...
			{
				if (q.dequeue())                   //and if dequeue is successful..
				{
					waitTime = clock - tempFront;  //wait time for job is current time minus the in time for job
					cout << "~~~~~A Customer was DeQueued~~~" << endl;
					cout << "Wait Time of Customer is: " << waitTime << endl;
					s.engage(i);
				}
				cout << "A server was successfully engaged" << endl;
				c.totalWait(waitTime);             //and total wait time is updated.
			}//end if isAvailable
		}//end server for loop
		for (i=0; i<servers; i++) //for loop runs from 0 to number of servers
		{
			if (!s.isAvailable(i))
			{
				s.incrementTrans(i); //the server's transaction time is decremented
			}
		}//end server for loop
		s.checkForTransaction();        //checks if a server needs to be dequeued
		cout << "clock: " << clock << endl;
		cout << "*************************************" << endl;
	} //end clock for loop
	int numberJobsLeft;
	int newClock = simTime - 1;
	int totalWaitinLine=0;
	while (q.checkLine())
	{
		int tempFront = q.front();        //temporary placeholder for front of queue
		waitTime = newClock - tempFront;  //wait time for job is current time minus the in time for job
		q.dequeue();                      //dequeue the front
		numberJobsLeft++;				  //add one to jobs left
		totalWaitinLine = totalWaitinLine + waitTime;  //update total wait time of jobs left
	}
	
	//display
	cout << "Jobs left in queue: " << numberJobsLeft << endl;
	cout << "Total Wait time of those left in queue: " << totalWaitinLine << endl;
	int jobsWaitedOn = numberOfJobsEnqueued;
	c.averageWait(jobsWaitedOn);
	c.display();
}
/*~~~Queue_of_Jobs.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |  Queue_of_Jobs handles the operations of the queue of jobs.  |
 |  Functions:                                                  |
 |    Queue_of_Jobs(): default constructor                      |
 |    bool enqueue(ElementType newJob): adds a job to the queue |
 |    bool dequeue(): removes a job from the front of the queue |
 |    int front(): returns the front value of the queue         |
 |    int size(): returns how many are in the queue              |
 |    bool checkForNewJob(int number): checks to add a job      |
 |    bool checkLine(): checks the queue for if there is a job  |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
#include <ctime>
#include <cstdlib>
#include "Queue_of_Jobs.h"

Queue_of_Jobs::Queue_of_Jobs()
{
	mySize = 0;
	frontOfQueue = 0;
	back = 0;
	count = 0;
}

bool Queue_of_Jobs::enqueue(ElementType newJob)
{
	if (mySize == capacity)
	{
		cout << "Queue is full." << endl << "Your simulation FAILS!" << endl
			 << "Try using smaller numbers..." << endl;
		exit(-1);
		return false;
	}
	else
	{
		myArray[back] = newJob;
		back = (back + 1)%capacity;
		count++;
		mySize++;
		return true;
	}
}

bool Queue_of_Jobs::dequeue()
{
	if (!checkLine()) //Queue is empty
	{
		return false;
	}
	else
	{
		ElementType j = myArray[frontOfQueue];
		if (frontOfQueue == capacity)
		{
			frontOfQueue = 0;
		}
		frontOfQueue = frontOfQueue + 1;
		count--;
		mySize--;
		return true;
	}
}

int Queue_of_Jobs::front()
{
	if (checkLine())
	{
		ElementType j = myArray[frontOfQueue];
		return (j.inTime);
	}
	else
	{
		//Queue is empty
		return 0;
	}
}

int Queue_of_Jobs::size()
{
	mySize = (back - frontOfQueue)%capacity;
	return mySize;
}

bool Queue_of_Jobs::checkForNewJob(int number)
{
	if (number%2)
		return true;
	else
		return false;
}

bool Queue_of_Jobs::checkLine()
{
	if (count >= 1)
		return true;
	else
		return false;
}
/*~~~Queue_of_Jobs.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |  Queue_of_Jobs handles the operations of the queue of jobs.  |
 |  Functions:                                                  |
 |    Queue_of_Jobs(): default constructor                      |
 |    bool enqueue(ElementType newJob): adds a job to the queue |
 |    bool dequeue(): removes a job from the front of the queue |
 |    int front(): returns the front value of the queue         |
 |    int size): returns how many are in the queue              |
 |    bool checkForNewJob(int number): checks to add a job      |
 |    bool checkLine(): checks the queue for if there is a job  |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
#include <string>
using namespace std;
typedef struct Job ElementType;

#define capacity 100

struct Job
{
	int inTime;
};

class Queue_of_Jobs
	{
	private:
		ElementType myArray[capacity];
		int mySize;
		int frontOfQueue;
		int back;
		int count;
	public:
		Queue_of_Jobs();
		bool enqueue(ElementType newJob);
		bool dequeue();
		int front();
		int size();
		bool checkForNewJob(int number);
		bool checkLine();
	};
/*~~~server.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |  The server handles the "serving" side of the simulation.    |
 |     The server acts as a bank teller might: engaging with    |
 |     customers, having a transaction time for while they      |
 |     work with a customer and so on.                          |
 |  Functions:                                                  |
 |    Server(): default constructor                             |
 |    bool isAvailable(int index): checks server for engaged    |
 |    void engage(int index): sets the server to not available  |
 |    void disEngage(int index): sets the server to available   |
 |    void insert(int numServers): inserts server to list       |
 |    void display(): displays the list of servers              |
 |    void setTransaction(int transTime): uses the user input   |
 |                                to set the transaction_time   |
 |    bool incrementTrans(int index): increments the server's   |
 |        serving time by one until it reaches transaction_time |
 |    bool checkForTransaction(): checks server for for need to |
 |                                disEngage.                    |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
using namespace std;
#include "server.h"

Server::Server()
{
	first = NULL;
	mySize = 0;
}

void Server::setTransaction(int transTime)
{
	transaction_time = transTime;
}

bool Server::incrementTrans(int index)
{
	NodePointer ptr = first;
	int i;
	for (i=0; i<index; i++)
	{
			ptr = ptr->next;
	}
	if (!isAvailable(index))
	{
		if (ptr->data.time == transaction_time)
			return false;
		else
		{
			int a;
			a = ptr->data.time;
			a++;
			ptr->data.time = a;
			return true;
		}
	}
	else
		return false;
}

bool Server::checkForTransaction()
{
	NodePointer ptr = first;
	int i;
	int count = 0;
	for (i=0; i<mySize; i++)
	{
		if (!isAvailable(i) && (ptr->data.time == transaction_time))
		{
			disEngage(i);
			cout << "Server was disEngaged!" << endl;
			count++;
		}
		else
			ptr = ptr->next;
	}
	if (count == 0)
		return false;
	else
		return true;
}

bool Server::isAvailable(int index)
{
	NodePointer ptr = first;
	int i;
	for (i=0; i<index; i++)
	{
		ptr = ptr->next;
	}
	if (ptr->data.avail == 0)
	{
		return true;
	}
	else if (ptr->data.avail == 1)
	{
		return false;
	}
}

void Server::engage(int index)
{
	NodePointer ptr = first;
	int i;
	for (i=0; i<index; i++)
	{
		ptr = ptr->next;
	}
	ptr->data.avail = 1;
	ptr->data.time = 0;
}

void Server::disEngage(int index)
{
	NodePointer ptr = first;
	int i;
	for (i=0; i<index; i++)
	{
		ptr = ptr->next;
	}
	if (ptr->data.avail == 0)
		cout << "server already disEngaged" << endl;
	else if (ptr->data.avail == 1)
	{
		ptr->data.avail = 0;
		ptr->data.time = 0;
	}
}

void Server::insert(int numServers)
{
	ServerType serv;
	int a = 0;
	int index;
	int i;
	for (index=0; index<numServers; index++)
	{
		serv.identity = index;
		serv.avail = a;
		serv.time = a;
		NodePointer nPtr = new Node(serv);
		nPtr->next = first;
		first = nPtr;
		mySize++;
	}
}

void Server::display()
{
	NodePointer ptr;
	ptr = first;
	while (ptr != NULL)
	{
		cout << ptr->data.identity
		     << " : " << ptr->data.avail 
		     << " : " << ptr->data.time << endl;
		ptr = ptr->next;
	}
	
}
/*~~~server.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |  The server handles the "serving" side of the simulation.    |
 |     The server acts as a bank teller might: engaging with    |
 |     customers, having a transaction time for while they      |
 |     work with a customer and so on.                          |
 |  Functions:                                                  |
 |    Server(): default constructor                             |
 |    bool isAvailable(int index): checks server for engaged    |
 |    void engage(int index): sets the server to not available  |
 |    void disEngage(int index): sets the server to available   |
 |    void insert(int numServers): inserts server to list       |
 |    void display(): displays the list of servers              |
 |    void setTransaction(int transTime): uses the user input   |
 |                                to set the transaction_time   |
 |    bool incrementTrans(int index): increments the server's   |
 |        serving time by one until it reaches transaction_time |
 |    bool checkForTransaction(): checks server for for need to |
 |                                disEngage.                    |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
#include <string>
using namespace std;

typedef struct aServer ServerType;

struct aServer
{
	int avail;
	int time;
	int identity;
};

class Server
	{
	private:
		int mySize;
		int transaction_time;
		class Node
		{
		public:
			ServerType data;
			Node * next;
			Node(ServerType ident){
				data = ident;
				next = NULL;
			}
		};
		typedef Node * NodePointer;
		NodePointer first;
		NodePointer predPtr;
	public:
		Server();
		bool isAvailable(int index);
		void engage(int index);
		void disEngage(int index);
		void insert(int numServers);
		void display();
		void setTransaction(int transTime);
		bool incrementTrans(int index);
		bool checkForTransaction();
	};
/*~~~Control.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |  Control handles the overall waitTime of customers and the   |
 |    average wait time for customers.                          |
 |  Functions:                                                  |
 |    Control(): default constructor                            |
 |    int totalWait(int waittime): keeps a running total for    |
 |                                 the time a job waits         |
 |    int averageWait(int numJobs): calculates the average wait |
 |    void display(): displays the total and average wait times |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
using namespace std;
#include "Control.h"

Control::Control()
{
	totalWaitTime = 0;
	averageWaitTime = 0;
}

int Control::totalWait(int waittime)
{
	totalWaitTime = totalWaitTime + waittime;
}

int Control::averageWait(int numJobs)
{
	averageWaitTime = totalWaitTime / numJobs;
}

void Control::display()
{
	cout << "Total Wait Time: " << totalWaitTime << endl;
	cout << "Average Wait Time was: " << averageWaitTime << endl;
}
/*~~~Control.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 |  Control handles the overall waitTime of customers and the   |
 |    average wait time for customers.                          |
 |  Functions:                                                  |
 |    Control(): default constructor                            |
 |    int totalWait(int waittime): keeps a running total for    |
 |                                 the time a job waits         |
 |    int averageWait(int numJobs): calculates the average wait |
 |    void display(): displays the total and average wait times |
 |                                                              |
 |  Author: Megan MacDonald                                     |
 |  Date Completed: April 3, 2009                               |
 |  Class: CSC 2110, section 002                                |
 |  Tennessee Technological University                          |
 |                                                              |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>

class Control
	{
	private:
		int averageWaitTime;
		int totalWaitTime;
	public:
		Control();  //default constructor
		
		//calculates the total wait time during simulation
		int totalWait(int waittime);
		
		//calculates the average wait time using totalWaitTime and number of jobs
		int averageWait(int numJobs);
		
		//displays the total wait time and the average wait time
		void display();
	};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.