create a framework for queues
$30-5000 USD
Paid on delivery
define the following structures:
struct SQueueNode {
char *cCard; // dynamic string
TQueueNode pNext;
} TQueueNode;
struct SQueue {
TQueueNode pFront; // pointer to the first element
TQueueNode pRear; // pointer to the last element
int iSize; // number of elements
} TQueue;
(b) The framework:
You are to create a framework for queues consisting of the following functions:
- TQueue *createQueue();
Initializes queue and returns a pointer to it.
- int enqueue(TQueue *q, char *c);
Enqueues 'c'. Returns 0 if the operation cannot be completed -- 1 otherwise.
- int dequeue(TQueue *q, char *c);
Dequeues to 'c'. Returns 0 if the operation cannot be completed -- 1 otherwise.
- int frontQueue(TQueue *q, char *c);
Retrieves the front of the queue to 'c'. Returns 0 if the operation cannot be completed -- 1 otherwise.
- int rearQueue(TQueue *q, char *c);
Retrieves a data from the rear of the queue to 'c'. Returns 0 if the operation cannot be completed -- 1 otherwise.
- void destroyQueue(TQueue *q);
Frees the memory allocated for the queue. Remeber to take care of freeing dynamic string before freeing the memory for the whole queue element.
(c) Problems to solve:
Using the framework defined above you are to implement the following functions:
- TQueue *readDeck();
Reads in a deck of cards (code for each card consists of two characters: card name and color, e.g. 10S for 10 Spades) and place the deck in a queue. You will be provided with the file containing a deck of cards -- you do not need to handle I/O errors, except checking if the file exists.
- void shuffleDeck(TQueue *q, int iShuffleCount)
Shuffles the deck. First splits the original deck into two decks (queues). Then shuffles taking cards from either of the new decks (use a random number generator to decide which deck to take card from at every iteration of the algorithm). Repeates shuffling 'iShuffleCount' times. The deck should be printed after every shuffle.
- void dealDeck(int iPlayersCount);
Deal the cards for 'iPlayersCount' people (<10). Here make use of an array of queues. Create a 1-dimentional array with 9 cells.
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
"Unix", Visual Studio 6.0
Project ID: #3122091