Skip to content

Ocelots Anna Du#17

Open
anjing0921 wants to merge 24 commits intoada-ac2:mainfrom
anjing0921:main
Open

Ocelots Anna Du#17
anjing0921 wants to merge 24 commits intoada-ac2:mainfrom
anjing0921:main

Conversation

@anjing0921
Copy link
Copy Markdown

No description provided.

Comment thread swap_meet/clothing.py
def __init__(self, id=None, condition=None, fabric=None) :
super().__init__(id, condition)
if fabric:
if type(fabric) is not str:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice extra error checking!

I would do this before the other code, so that the error is generated first, before extra work is unnecessarily done.

Comment thread swap_meet/electronics.py
def __init__(self, id=None, condition=None, type=None) :

super().__init__(id, condition)
if type:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is clean code, though it could be a ternary operator.

Comment thread swap_meet/item.py

return f"An object of type Item with id {self.id}"

def condition_description(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done-- though now, you probably can see the advantages of a dict for this. O(1) lookup, vs, O(n) for the worse case of falling through n conditions in an if/else :)

Comment thread swap_meet/vendor.py
if my_item not in self.inventory or their_item not in b_vendor.inventory :
return False
else:
self.remove(my_item)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good use of making use of existing vendor functions, rather than re-implementing that logic here again!

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