hi every body

can any one help how to start with this project


using the c++ ADT class ,write aprogram that simulates the operation
of telephone system that might be found in asmall business,
such as your local pizza parlor.Only one person can answer
the phone(aingle server queue).
but there can be an unlimited number of calls waiting to be answered.
Queue analysis consider two primary elements, the length of time
a requester waits for service(the queue wait time -in this case)
the customer calling the pizza) and the service time
(thr time it takes the customer to place the order).
Your program will require two inputsto run the simulation:
(1)the length of time in hours that the service will be provided.
(2)the maximum time, it takes for the operator to take an order
(the maximum service time) .

4 element are required to run the simulation:
1. Timing loop:
every iteration of the loop will be conseder 1 min in real time.
the loop will continue until the service has been in operation the requisted amount of time. when the operating period is complete,how ever,the timing has the follwing subfunctions:
a.datermine wether a call was recieved
b. process active call.
c. start new call.

2. call simulator:
it will use a random num. generator to detemine whether a call has been recieved.Scale random numberto an appropriate range,such as 1 to 10.
The random num. should be compared with a define constant .If the value is < const. ,a call was received ;if it's not,then no call was received.
for the simulation set tje call level 50%,on the average.
a call will received every 2 min. , if a call is recieved ,place it in a queue.

3. process active call:

if acall is active ,test whether it has been completed, if completed print the statistics for the current call and gather the necessary statistics
for the end of the job report.

4.start new call:
if there are no active calls, start new call, if there is one waiting in the queue .Note that starting a call must calculate the time the call has been waiting.

/* sample queue output

ColckTime CallNumber ArrivalTime WaitTime startTime ServiceTims QueueSize
4 1 2 0 2 3 2
6 2 3 2 5 2 4

*/

If anyone has any suggestions I would really appreciate it

Recommended Answers

All 5 Replies

//	Node Declaration
	template <class TYPE>
	struct NODE  
	{
	 TYPE        data;
	 NODE<TYPE> *next;
	};
   
//	Class Declaration
	template <class TYPE>
	class Queue 
	{
	 private:
	    NODE<TYPE>  *front; 
	    int          count; 
	    NODE<TYPE>  *rear; 

	 public:
	       Queue      (void);
	      ~Queue      (void);
	 bool  dequeue    (TYPE& dataOut);
	 bool  enqueue    (TYPE  dataIn);
	 bool  queueFront (TYPE& dataOut);
	 bool  queueRear  (TYPE& dataOut);
	 int   queueCount (void);
	 bool  emptyQueue (void);
	 bool  fullQueue  (void);
	 bool enqueueWithoutNegative (TYPE dataIn);
	 


	}; // class Queue
					
/*	================== Constructor  =================	
	Instantiates a queue and initializes private data.
	   Pre     queue being defined
	   Post    queue created and initialized
*/

template <class TYPE>
Queue<TYPE> :: Queue (void)
{
//	Statements 
	front  = NULL;
	rear   = NULL;
	count  = 0;
}	// Constructor 

/*	================== enqueue ================= 
	This algorithm inserts data into a queue.
	   Pre    dataIn contains data to be enqueued
	   Post   data have been inserted
	   Return true if successful, false if overflow 
*/

template <class TYPE>
bool Queue<TYPE> :: enqueue (TYPE dataIn)
{
//	Local Definitions 
	NODE<TYPE>  *newPtr;

//	Statements 
	if (!(newPtr = new NODE<TYPE>))
	    return false;
		
	newPtr->data = dataIn; 
	newPtr->next = NULL; 
  
	if (count == 0)
	    // Inserting into empty queue 
	    front  = newPtr;
	else
        rear->next = newPtr; 

	count++;
	rear = newPtr;
	return true;
}	//enqueue

/*	================= dequeue ================== 
	This algorithm deletes a node from the queue.
	   Pre    dataOut variable to receive data
	   Post   front data placed in dataOut and front deleted
	   Return true if successful, false if underflow 
*/
template<class TYPE>
bool Queue<TYPE> :: dequeue (TYPE& dataOut) 
{
//	Local Definitions 
	NODE<TYPE>  *deleteLoc;

//	Statements 
	if (count == 0)
	    return false;
	 
	dataOut   = front->data;
	deleteLoc = front;
	if (count == 1)
	    // Deleting the only item in queue 
	    rear = front = NULL;
	else
	    front = front->next;
	count--;
	delete deleteLoc;

	return true;
}	// dequeue 

/*	================== queueFront ================== 
	Retrieves data at the front of the queue
	without changing the queue contents. 
	   Pre    dataOut is variable for data
	   Post   data in dataOut
	   Return true if successful, false if underflow 
*/

template <class TYPE> 
bool Queue<TYPE> :: queueFront (TYPE& dataOut) 
{
//	Statements 
	if (count == 0) 
	    return false;
	else
	   {    
	    dataOut = front->data;
	    return true;
	   } //else
}	// queueFront 

/*	=============== queueRear ============== 
	Retrieves  data at the rear of the queue
	without changing the queue contents. 
	   Pre    dataOut is variable to receive data
	   Post   dataOut contains data at rear of queue
	   Return true if successful, false if underflow 
*/

template <class TYPE> 
bool Queue<TYPE> :: queueRear (TYPE& dataOut) 
{
//	Statements 
	if (count == 0) 
	    return false;
	else 
	   { 
	    dataOut = rear->data;
	    return true;
	   } // else 
}	// queueRear 

/*	=================== emptyQueue ================== 
	This algorithm checks to see if a queue is empty. 
	   Pre    nothing
	   Return true if empty, false if queue has data 
*/

template <class TYPE> 
bool Queue<TYPE> ::  emptyQueue (void) 
{
// Statements 
	return (count == 0);
}	// emptyQueue 

/*	=================== fullQueue =================== 
	This algorithm checks to see if a queue is full. 
	The queue is full if memory cannot be allocated 
	for another node. 
	    Pre    nothing
	    Return true if full, false if room for a node
*/

template <class TYPE>
bool Queue<TYPE> :: fullQueue (void) 
{
//	Local Definitions  
	NODE<TYPE>  *temp;

//	 Statements 
	temp = new NODE<TYPE>;
	if (temp != NULL)
	   {
	    delete temp;
	    return false;
	   } // if 

	// Heap full 
	return true;
}	//  fullQueue 

/*	=============== queueCount ============== 
	Returns the number of elements in the queue.
	   Pre    nothing
	   Return queue count 
*/

template <class TYPE> 
int Queue<TYPE> :: queueCount(void) 
{
//	Statements 
	return count;
}	// queueCount 

/*	=================== Destructor ================== 
	Deletes all data from a queue and recycles 
	its memory.
	   Pre    queue is being destroyed
	   Post   all data have been deleted and recycled
*/

template <class TYPE> 
Queue<TYPE> :: ~Queue (void) 
{
//	Local Definitions 
	NODE<TYPE>   *deletePtr;

//	Statements 
	while (front != NULL) 
	   {
	    deletePtr = front;
	    front = front->next; 
	    delete deletePtr; 
	   } //  while 
}	// Destructor

this is the ADT

Write down in words what the program should do in detail, then translate that into code.

If you know modelling tools, you can use those too.
Make things like state transition diagrams, flow diagrams, etc.
It doesn't really matter, but understand what the code should do and how you want it to do it and quite often the code will start to seem to write itself.

It's hard to explain I know, I don't know how it starts to happen but it does.
It's probably a subconscious process that you need to tap into, once you reach that the actual programming language becomes an implementation detail. While it won't allow you to program in languages you don't know it does allow you to more easily learn languages and use them, to read existing code and understand it.

So start by writing out in words exactly what happens when, and then figure out how your ADT fits into that.

i know the idea but i can't convert it to codes

write it down. How would you solve it on paper?
Forget that computer. Turn off your screen and get pen and paper.

Every problem can be solved without computers, it just takes time (in some cases more time than there is, but the idea is not to solve the problem but to determine HOW to solve it).
Work it out in detail, small steps.

Then when you have all that written down, think of how you'd tell the computer to do each of the small steps you've determined.

If you can't write it in english you won't be able to write it in c++.

A quote from my teacher, "the sooner you start to code, the longer the program will take to write".

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.