Skip to content

Commit

Permalink
updated multiple interitance and duck-typing chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanNilsen committed Jul 20, 2020
1 parent c3d4b23 commit 3e62d8c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ class PettingZoo(Attraction):

def __init__(self, name, description):
super().__init__(name, description)

def addAnimal(self, animal):
self.animals.append(animal)

```
Don't forget to add the module imports to the attractions package.
Expand Down
4 changes: 2 additions & 2 deletions book-1-orientation/chapters/CLASSES_08-DUCK_TYPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
>
>In Python, lists can contain any combination of object types. A single list could contain an integer, a boolean, and a string. This means that the `animals` attribute of your attractions classes can contain **any** critter type, regardless of whether it belongs there.
>
>You decide that you'll need to add a check to the `addAnimal` method of your attractions classes to make sure a critter belongs in the attraction you're adding it to. Luckily, you already have a built-in way of determining what kind of critter you're dealing with...
>You decide that you'll need to add a check to the `add_animal` method of your attractions classes to make sure a critter belongs in the attraction you're adding it to. Luckily, you already have a built-in way of determining what kind of critter you're dealing with...
### Using Your Inherited Class Properties to Restrict Lists

Expand Down Expand Up @@ -32,7 +32,7 @@ class PettingZoo(Attraction):
# Number 2: Actual typing check
def add_animal_type_check(self, animal):
if isinstance(animal, Swimming):
self.animals.add(animal)
self.animals.append(animal)
else:
print(f'{animal} doesn\'t like to be petted, so please do not try to put it in the {self.name} attraction.')
```
Expand Down

0 comments on commit 3e62d8c

Please sign in to comment.