
Today We did
– Reviewing Dictionaries and classes
Homework
# Classes /objects
#Classes are templates for creating things with unique info/actions
class Character():
# initialize proccess
#The goal here is to take information and assign it to our character
def __init__(self,name,hp, attack):
self.name=name
self.hp = hp
self.attack=attack
def fight(self):
print(f"{self.name} uses {self.attack}")
# Object, taking the templates we create, and make a character
my_hero = Character("Mario", 2, "Jump Attack")
print(my_hero.name)
print(my_hero.fight)
# Combining Classes and Dictionaries
# Part 1:
# I want you to create a Dictionary called Team (keep it empty for your first line_
# I want you to then create three different characters, with the class we just made
# add them to the dictionary. the key will be a number (1,2, or 3), the value will be
# there heroes you create
# Part 2: Go down a few lines (same file) and lets practice grabbing from the dictionary
# to do stuff
# i need you to go into your dictionary, and make the second hero attack (use .fight)
# I need you to go into your dictionary and tell me the the name of the third hero
# I need you to print with a for loop,print each characters hp