A class is a way to create an object and give that object properties. For example, let's say you want to create a class for summer shirts (the object). According to you, all summer shirts must have these properties:
🌟 Classes create objects with the same properties and are written as class ClassName:
TreeNode is capitalized on the T and the N because that's how Python recognizes it as a class. If it weren't, it may be read as a variable instead.
The starting node is called the root node and this is where the story begins branching off into scenarios. Remember to indent this line of code if it's not lined up like in the video by using the tab key.
We define a function by typing def and remember that the function syntax always use parentheses. You cannot use a function before defining it because the computer won't understand what to do. It's like if I asked you to "Defenestrate the collagenous tallow posthaste!" would you know what to do? Probably not, unless I explained it first.
Functionsare packets of code that do a certain task and are always followed by ( ). Here we have a __init__() function.
Every time we start a class we will code an initialization function to get it started.
The parameters we are passing through the initialization function are self and story_piece.
Parametersare things that get passed into a function.
Think of it like if you have a function called washDishes() and the order was soap, rinse, then dry. Now all the dinner plates and cups that need to be cleaned will be passed through this function and will get soaped, rinsed, and dried. I could say, "Hey buddy! I need you to washDishes()" and you'd know what to do.
Accessing this project requires a login, please enter your credentials below!