Topics: - C/C++ Syntax - Pointers - Dynamic Allocation of Memory - Data Structures: Linked Lists - Object Orientation Overall Specifications: You are to create a Doubly-LinkedList or Binary Search Tree data structure from scratch. This structure should be Templated so that any data could be stored within it. You are creating a data structure here from scratch. You may use std::string (\#include ) if needed. You may use other built-in structures to support your algorithms (arrays for string tokenizing for example) but you are creating your own LinkedList or BST. The primary goal of this assignment is to make a LinkedList/BST that you can use and re-use. The data structure itself is the majority of the specifications grade. Specifications Scoring Breakdown: You are eligible for these points in the Specifications part of the rubric if you accomplish: - Templated Linked List/BST + Problem - 100\% of Specifications - Templated Linked List/BST only + Thorough Test - Max B on Specifications on Rubric - Untemplated Linked List/BST + Problem - Max B on Specifications on Rubric - Untemplated Linked List/BST only + Thorough Test - Max C on Specifications on Rubric The rest of the rubric is graded as normal. ** BIG GIANT NOTE - TEMPLATES AND FILES ** When you use a templated type in C++, ALL templated code must be done in the .h file. This means that ALL of your methods will be defined in the .h file as well as your class. You should still forward declare Classes above and then implement the Methods below. Your .h file should have both, your LinkedList/BST and Node classes, and their method definitions. Remember to use your : : operator correctly. Feel free to use friendship if needed.
Zombie Conga Party! - Linked Lists You will create a Doubly-LinkedList Class and a Node Class. The LinkedList should contain the following methods in its public interface: NOTE: \( T \) stands for the template data type, so \( T \) data means the variable of type \( T \) (whatever \( \mathrm{T} \) is) - Constructor - Destructor - AddToFront( \( T \) data) :void - create a node containing \( T \) data and add it to the front of the list - AddToEnd( \( T \) data) :void - create a node containing \( T \) data and add it to the end of the list - AddAt Index(T data, int index) :bool - create a node containing \( T \) data and add it to the list at index. The new node containing the data will be the \#index node in the list. Return boolean for success or failure (optional: you could also return an integer with failure codes since this method can fail multiple ways) - AddBefore(Node \( \angle T>*, T \) data) : void - create a node containing \( T \) data and add it before a particular node - AddAfter (Node*, T data) : void - create a node containing \( T \) data and add it after a particular node - RemoveFromFront(): \( T \) - Delete first item and return its contents - RemoveFromend(): \( T \) - Delete last item and return its contents - RemoveThefirst(T data) :void - find first instance of \( T \) data and remove it - RemoveAllof(T data):void - find each instance of \( T \) data and remove it - RemoveBefore \( \left(\right. \) Node \( \left.\langle T\rangle^{\star}\right): T \) - delete the node before a particular node, return its contents - RemoveAfter (Node \( \left\langle T T^{*}\right): T \) - delete the node after a particular node, return its contents - Elementexists (T data) :bool - Returns a T/F if element exists in list - Find(T data): Node \( \langle T P \star \) - Look for data in the list, return a pointer to its node - Indexof(t data):int - returns an index of the item in the list (zero-based) - RetrieveFront:T - returns the data contained in the first node, does not delete it - RetrieveEnd:T - returns the data contained in the last node, does not delete it - Retrieve(int index): \( T \) - returns the data contained in node \# index, does not delete it, throw a "index out of bounds" exception if the index does not exist - https://www.tutorialspoint.com/cplusplus/cpp_exceptions_handling.htm - Printlist:void - Loop through each node and print the contents of the Node - Empty:void - Empty out the list, delete everything - Length:int - How many elements are in the list More methods private or public should be created as needed to facilitate the functionality of the Interface methods. If you feel your list needs more functionality, feel free to create it.
Node Class - Constructor - Destructor - Getters \& Setters The node class should be fairly rudimentary. Ideally, it should be templated so you can store anything in it. As per usual, I have not made a perfect representation of the parameters you might need, etc. I have made suggestions where appropriate, but you might need more depending on how you code things. Zombie Class - Constructor - Getters The Zombie class is very simple, don't give it any more work to do. Conga (class?) You can create a class for your Conga or you can create a set of functions. Description: You are going to create a silly Zombie Conga Line using your Linked List. Each node is going to store a Zombie in it. Zombies can be Red, Yellow, Green, Blue, Magenta and Cyan. Every turn you will randomly generate a Zombie object and an action. You will then perform that action using the Zombie object as the parameter for that action. Notes These actions are external to the Linked List. They are accomplished by calling Linked List methods . These actions are not part of your Zombie class. Zombies are very simple classes and have no responsibility for Conga actions.
Actions: - Engine! o This zombie becomes the first Zombie in the conga line - Caboose! - This zombie becomes the last zombie in the conga line - Jump in the Line! - This zombie joins the conga line at position \( \mathrm{X} \) where \( \mathrm{X}<= \) length of the linked list - Everyone Out! - Remove all matching zombies from the linked list - You're done! - Remove the first matching zombie from the linked list - Brains! o Generate two more matching Zombies and add one to the front, one to the end and one to the middle (round down). - Rainbow Brains! - Add this zombie to the front, then add one of each zombie color to the end of the conga line. - Making new Friends! - Find the first Zombie of this color in line. "Flip a coin" 50\% chance of adding before or after that zombie. - If no Zombie of that color exists, add this one before the Tail zombie - Unstable Zombie o Walk the list to locate the first Zombie of this color in line and remove it. - As you walk the list: the all zombies of other colors before the target zombie splits and adds a new zombie before them. - \( \rightarrow \mathrm{G} \rightarrow \mathrm{R} \rightarrow \mathrm{B} \rightarrow \mathrm{R} \rightarrow \mathrm{Y} \rightarrow \mathrm{C} \rightarrow \mathrm{G} \) - Generate C - \( \rightarrow \mathrm{G} \rightarrow \mathrm{G} \rightarrow \mathrm{R} \rightarrow \mathrm{R} \rightarrow \mathrm{B} \rightarrow \mathrm{B} \rightarrow \mathrm{R} \rightarrow \mathrm{R} \rightarrow \mathrm{Y} \rightarrow \mathrm{Y} \rightarrow \mathrm{G} \) Every 5 rounds remove the Head zombie and Tail zombie. Setting up the List: Set up the initial Conga Line by running these actions: 1. Run a Rainbow Brains! Action 2. Run a random number (between 2 and 5) of Brains actions User Interface: - Ask the user how many rounds they want to run. - Then generate that many random actions and fulfill them. - If the conga line ever empties completely due to an action tell the user that the Party is Over. - Once the number of rounds has finished. Ask the user if they want to continue the party or end. - If they choose to continue ask them for a new number of rounds to run.
Output: Each round you'll output the entire Linked List. You can represent each zombie as a single character corresponding to their \( \operatorname{color}(\mathrm{R}, \mathrm{Y}, \mathrm{G}, \mathrm{B}, \mathrm{M}, \mathrm{C}) \). Have fun, make silly messages and color the output if you like! You'll show the zombie generated and the action generated. Then you'll show the outcome of the action. Spelling it out for you: You should create the following classes: 1. LinkedList 2. Node 3. Zombie Your Nodes should store Zombies. Your LinkedList is made of Nodes. Hints: Build robust constructors and use them! Your Node and your Zombie will benefit highly from good constructors. Do yourself a favor and overload the == operator in your zombie. It will make life easier! Overload the cout for your Zombie. It'll make your printlist method easier. You might consider making the Conga its own class so you can make each of the actions a method in the conga class. Extra Credit: \( +2 \) - Color your Zombies in the output.
Sample output: Round: 0 The Zombie Party keeps on groaning! B zombie jumps in the front of the line! (ENGINE) The conga line is now: Round: 1 The Zombie Party keeps on groaning! Size: \( 17::[B] \) [R] [M] [G] [R] [R] [G] [G] [R] [M] [B] [Y] [M] [C] [G] [M] [R] \( M \) zombie jumps in the front of the line! (ENGINE) The conga line is now: Round: 2 The Zombie Party keeps on groaning! Size: \( 18::[M] \) [B] [R] [M] [G] [R] [R] [G] [G] [R] [M] [B] [Y] [M] [C] [G] [M] [R] C zombie pulls up the rear! (CABOOSE) The conga line is now: Size: \( 19::[M][B][R][M][G][R][R] \quad[G][G][R][M][B][Y][M] \) [C] [G] [M] [R] [C] Round: 3 The Zombie Party keeps on groaning! \( \begin{array}{lllllllllllllll}\text { Size: } 19:: & \text { [M] [B] [R] [M] [G] } & \text { [R] [R] [G] [G] [R] } & \text { [M] } & \text { [B] } & \text { [Y] } & \text { [M] } & \text { [C] } & \text { [G] } & \text { [M] } & \text { [R] } & \text { [C] }\end{array} \) \( \mathrm{Y} \) zombie brought a whole party itself! (RAINBOW BRAINS!) The conga line is now: Size: [C] Round: 4 The Zombie Party keeps on groaning! [C] \( \mathrm{Y} \) zombie brings its friends to the party (BRAINS!) The conga line is now: [Y] [M] [C] [Y] NOTE: You don't have to use my messages, I just made them on a whim. Do however follow my lead and put a label showing what action the message represents. Don't forget to output the list before and after the action.