初学者,如有错误请指点。
bool do_command(char c,Extened_queue&text_queue)
{bool continue_input=true;
Queue_entry=x;
switch(c)
{
case'a':
if(text_queue.append(x)==overflow)
cout<<"Queue is full."<<endl;
else
cout<<x<<"is added to the rear of the Queue."<<endl;
break;
case's':
if(text_queue.serve()==underflow)
cout<<"The Queue is empty."<<endl;
else
cout<<"The front of the queue is removed."<<endl;
break;
case'r':
if(text_queue.retrieve(x)==underflow)
cout<<"Queue is empty."<<endl;
else
cout<<"The firet entry is:"<<x<<endl;
break;
case'#':
cout<<"The current of the extended queue is:"
<<text_queue.count<<endl;
break;
case'c':
if(text_queue.empty())
cout<<"The Queue is empty."<<endl;
else
while(!text_queue.empty())
{
text_queue.serve();
}
break;
case'p':
if(text_queue.empty())
cout<<"The Queue is empty."<<endl;
else
while(!text_queue.empty())
{
text_queue.retrieve(x);
cout<<"The extended Queue is:"<<endl;
cout<<x<<" ";
text_queue.serve();
}
break;
case'h':
help();break;
case'q':
cout<<"Extended queue demonstration finished."<<endl;
continue_input=false;
break;
}
return continue_input;
}