Programing c a childs selection


Implement a child's selection game. In the standard version of this game a group of children gather in the circle and begin a rhyme. Each word of the rhyme is chanted in turn by 1 person in the circle. The last person is out of the game, and the rhyme is restarted from the next person. Eventually, 1 person is left and he or she is the lucky individual who gets selected.

Your application should read the total number (or names) of players and the words of the rhyme from the keyboard. The intermediate output are numbers (or names) of players called by each word of a rhyme, players that get removed from the circle after each round, and updated lists of players. The final output is the number (or name) of one remaining (selected) player.

Details of implementation.

Use an array of strings rhyme for storing list of words in the rhyme and circular doubly linked list (of integers or strings) for storing players.

Create files CircLinkedList.h and CircLinkedList.c with declarations and implementations of the following functions. Header file CircLinkedList.h should also contain definitions of types: Node (structure with fields data, next, and prev), NodePtr, LinkedList (structure with fields head and tail) and LinkedListPtr.

• LinkedListPtr initLinkedList() /*allocates dynamic memory for the linked list, initializes its head and tail to NULL */

• void insertTail(LinkedListPtr list, int data) /*inserts a new node containing data after the last node, but if the list is empty - as the head of a linked list */

• void display(LinkedListPtr list, NodePtr start) /*displays all the data in a circular doubly linked list, starting from a start node*/

• void removeNode(LinkedListPtr list, NodePtr nodeToDelete) /*removes a node from a circular doubly linked list

Create application file CountingGame.c containing the following functions

• NodePtr sayRhyme(char rhyme[MaxNumWords][MaxWordSize], int numWords, LinkedListPtr list, NodePtr startingPlayer) /*simulates one round of the game:

? output the player starting a rhyme

? for each word in the rhyme print out the player and the word that he says

? output the player which is to be removed (the one who says the last word) and the next one in a list - the new starting player (store the pointers to the nodes containing these players)

? remove the player from the list (calling removeNode)

? print out the updated list of players (calling display)

? return the pointer to the node storing the new starting player */

Sample output of sayRhyme:

Starting this round from Player 1

Player 1 says "eeny",

Player 2 says "meeny",

Player 3 says "miny",

Player 1 says "moe"

Player 1 is removed

Starting the next round from Player 2 (next after Player 1).

Remaining players: 2,3.

• int main(int argc, char argv[])

creates and displays an array of words in a rhyme (inputted by a user) and a list of players,

then simulates playing the game repeatedly calling sayRhyme in a loop until it has just 1 player (startingPlayer ->next== startingPlayer),

which is then announced a winner of the game */

Solution Preview :

Prepared by a verified Expert
Programming Languages: Programing c a childs selection
Reference No:- TGS01129011

Now Priced at $60 (50% Discount)

Recommended (99%)

Rated (4.3/5)