Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.227.190.231
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/mjsmith/../zvhope/../rnlink/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/mjsmith/../zvhope/../rnlink/queueclient.cpp
// CopyNth Test Driver for either Queue implementation
//
// Important:  Make sure your MAXQUEUE = 6

#include <iostream>
#include "queuearray.h"  // to test array implementation
// #include "queuell.h"     // to test array implementation
using namespace std;

int main ()
{

QueueType<char> chqueue;  // test queue

char copych;              // holds character viewed with CopyNth

// Enqueue some items

chqueue.Enqueue ('A');
chqueue.Enqueue ('B');
chqueue.Enqueue ('C');
chqueue.Enqueue ('D');
chqueue.Enqueue ('E');

// Do some CopyNth calls - queue currently has 5 values

cout << "\nTesting CopyNth for queue with 5 items";

chqueue.CopyNth (5, copych);
cout << "\n\nThe 5th value should be E and it is " << copych;

chqueue.CopyNth (1, copych);
cout << "\n\nThe 1st value should be A and it is " << copych;

chqueue.CopyNth (3, copych);
cout << "\n\nThe 3rd value should be C and it is " << copych;

//  Dequeue 4 items, then Enqueue 3 more

chqueue.Dequeue (copych);
chqueue.Dequeue (copych);
chqueue.Dequeue (copych);
chqueue.Dequeue (copych);
chqueue.Enqueue ('F');
chqueue.Enqueue ('G');
chqueue.Enqueue ('H');

//  Do some CopyNth calls

chqueue.CopyNth (4, copych);
cout << "\n\nThe 4th value should be H and it is " << copych;

chqueue.CopyNth (3, copych);
cout << "\n\nThe 3rd value should be G and it is " << copych;

chqueue.CopyNth (2, copych);
cout << "\n\nThe 2nd value should be F and it is " << copych;

chqueue.CopyNth (1, copych);
cout << "\n\nThe 1st value should be E and it is " << copych;

chqueue.Dequeue (copych);
chqueue.Dequeue (copych);
chqueue.Dequeue (copych);
chqueue.Dequeue (copych);

// Queue should now be empty

if (chqueue.IsEmpty())
   cout << "\n\nQueue is empty, as it should be\n\n";
else
   cout << "\n\nQueue isn't empty, but should be - uh-oh!\n\n";

return 0;

}


Stv3n404 - 2023