Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whales_GabyWebb #95

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Whales_GabyWebb #95

wants to merge 27 commits into from

Conversation

gabw13
Copy link

@gabw13 gabw13 commented Apr 8, 2022

No description provided.

Copy link

@alope107 alope107 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job Gaby! Really nice use of inheritance and method re-use to DRY your code! This project is green~

Comment on lines +3 to +5
def __init__(self, category="Clothing", condition=0):
super().__init__(category, condition)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great use of super here! Consider removing the category from the constructor arguments on line 3. We know we always want it to be "Clothing" so we don't want to allow changing it when instantiating an instance.

Comment on lines +9 to +23
'''returns string description of item condition'''
if self.condition == 0:
description = "Trash"
elif self.condition == 1:
description = "It Works"
elif self.condition == 2:
description = "Decent"
elif self.condition == 3:
description = "Good"
elif self.condition == 4:
description = "Like New"
elif self.condition == 5:
description = "New"
return description

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job having this be defined here once and inherited by the child classes!

Comment on lines +2 to +5
self.inventory = inventory
if self.inventory is None:
self.inventory = []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job avoiding a mutable default argument!

Comment on lines +7 to +10
'''adds item to inventory'''
self.inventory.append(item)
return item

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great docstrings here and elsewhere!

Comment on lines +27 to +36
'''swaps items between vendor inventories'''
if my_item not in self.inventory or their_item not in vendor.inventory:
return False
else:
self.inventory.remove(my_item)
vendor.inventory.append(my_item)
vendor.inventory.remove(their_item)
self.inventory.append(their_item)
return True

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great logic! One small thing: the else is unneeded here because the if block returns and ends the function if it's entered.

Comment on lines +38 to +45
'''
swaps items between vendor inventories
by first position in inventory
'''
if self.inventory and vendor.inventory:
return self.swap_items(vendor, self.inventory[0], \
vendor.inventory[0])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love how you re-use your earlier method! One small bug here: according to the README this method should return False if either of the inventories is empty, but it actually returns None.

Comment on lines +59 to +73
'''
swaps best condition items of a given category
between vendor inventories
'''
if not self.inventory or not other.inventory:
return False
elif not self.get_by_category(their_priority) or \
not other.get_by_category(my_priority):
return False
else:
self_best_item = self.get_best_by_category(their_priority)
their_best_item = other.get_best_by_category(my_priority)
self.swap_items(other, self_best_item, their_best_item)
return True

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great logic! Similar note to earlier how the else is not needed.

Comment on lines +41 to +44
assert len(items) == 0
assert item_a not in items
assert item_b not in items
assert item_c not in items

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of these asserts, but I think the last 3 are unneeded. If the length of items is 0, we already know none of the specified items are inside it.

Comment on lines +85 to +95
assert result == True
# - That tai and jesse's inventories are the correct length
assert len(tai.inventory) == 3
assert len(jesse.inventory) == 3
# - That all the correct items are in tai and jesse's inventories, including the items which were swapped from one vendor to the other
assert item_f in tai.inventory
assert item_a in tai.inventory
assert item_b in tai.inventory
assert item_c in jesse.inventory
assert item_d in jesse.inventory
assert item_e in jesse.inventory

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great asserts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants