Linked List Methods #
This lab is for practicing implementing Linked List methods in context.
Syllabus Topics [HL] #
- B4.1.2 Evaluate linked lists. (HL only)
- B4.1.3 Construct and apply linked lists: singly, doubly and circular. (HL only)
[0] Set up #
๐ป Clone your repo. This will copy it onto your computer.
Be sure to replace yourgithubusername with your actual username.
cd ~/desktop/dpcs/unit03_oop
git clone https://github.com/isf-dp-cs/lab_linked_list_methods_yourgithubusername
cd lab_linked_list_methods_yourgithubusername
๐ป Enter the Poetry Shell to start the lab. As a reminder, we will run this command at the start of each lab, but only when we are inside a lab folder.
poetry shell
๐พ ๐ฌ Exiting the poetry shellWhen you want to exit the shell, you can type
exitor^D
[1] Whiny Babies #
Create a whiny babies game that will allow each player to add complaints to the front of the linked list.
You will have to complete the implementation of a singly LinkedList in linked_list.py.
add_front() #
Each complaint should be smaller and stupider (more trivial) than the previous one. This should use linked_list.add_front().
๐ป Completeadd_front().
remove_front() #
The other player can reject the most recent addition if its not sufficiently whiny/trivial. This should use linked_list.delete_front()
๐ป Completedelete_front().
printing #
๐ป Finish the method __str__ which will allow you to print() the linked list to show the complaints.
Whiny Babies Game #
๐ป Create a the game in whiny_babies.py.
You can utilize the Complaints class too store your complaints, if desired, to increase the complexity.
The game should alternate turns between two players. If one players things the other’s complaint isn’t sufficiently whiny, they can reject it, and it should get removed from the front of the list, and the whole list should be printed.
[2] Collaborative Story #
The collaborative story is similar to whiny babies, but new additions get added onto the end to create a narrative.
It will also use the LinkedList class.
Required methods #
๐ป Create a method add_last() which adds a new Node to the end of the linked list.
๐ป Create a method delete_last() which removes the last Node from the end of the linked list.
Story Game #
๐ป Create a the game in whiny_babies.py.
You can create a new class to store the story part objects, if desired.
[3] Spinning Game #
This game will utilize multiple circular linked lists to simulate a spinning game.
Create a spinning game that uses multiple linked lists to store various emojis. The game should allow players to trigger a random spinning, that utilizes the nature of a circular linked list to simulate continuous spinning.
What methods will your circular linked lists nee
๐ป Create a method that will allow you to insert data into your circular linked list.
๐ป Create the spinning game.
[4] Deliverables #
โกโจ Once you finish the lab, be sure to complete these two steps:๐ Update Syllabus Checklist: Go to your Syllabus Content Checklist in your Google Drive and update it accordingly.
๐ป Push your work to Github
- git status
- git add -A
- git status
- git commit -m “describe your code here”
- git push
- remote