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

Lions - Nancy L #101

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

Lions - Nancy L #101

wants to merge 17 commits into from

Conversation

nancy-lee89
Copy link

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.

There's some really great logic here! I also love how frequent your commits are. There are a few places where inheritance isn't fully taken advantage of and there are there are a few tests that aren't passing, so this project is a yellow. That being said, really nicely done with what you've got here!

from hashlib import new

Choose a reason for hiding this comment

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

Oops! Looks like VS Code accidentally auto-imported something you didn't want here. Make sure to double-check for these and deleted unneeded imports.

Comment on lines 4 to 7
def __init__(self, category="Clothing", condition=0):
self.category = category
self.condition = condition

Choose a reason for hiding this comment

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

While this works, we would prefer to use super here to take advantage of the constructor for Item.

We also would prefer to not have category be an optional argument - we know that we always want the category to be "Clothing".

Comment on lines 1 to 3
from distutils.archive_util import make_archive
from operator import itemgetter
import py_compile

Choose a reason for hiding this comment

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

Looks like a few more accidental imports from VS Code here.

Comment on lines 4 to 11
class Item:
pass No newline at end of file
def __init__(self, category="", condition=0):
self.category = category
self.condition = condition

def __str__ (self):
return "Hello World!"

Choose a reason for hiding this comment

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

Great!

Comment on lines +13 to +25
if self.condition == 0:
return "poor"
elif self.condition == 1:
return "fair"
elif self.condition == 2:
return "good"
elif self.condition == 3:
return "excellent"
elif self.condition == 4:
return "perfect"
elif self.condition == 5:
return "new"

Choose a reason for hiding this comment

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

This works well if the condition is an integer, but what would happen if the condition was a float like 3.5 as it is in some of the tests? Can you think of how you would solve this issue?

Comment on lines +38 to +43
if len(self.inventory) == 0 or len(friend.inventory) == 0:
return False
else:
self.swap_items(friend, my_item=self.inventory[0], their_item=friend.inventory[0])
return True

Choose a reason for hiding this comment

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

Great use of your helper!

Comment on lines 48 to 56
# loop through the self.inventory
best_item = None
for item in self.get_by_category(category):
if best_item == None:
best_item = item
elif item.condition > best_item.condition:
best_item = item
return best_item

Choose a reason for hiding this comment

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

Really nice logic and awesome re-use of get_by_category! One small change, use is instead of == to check whether something is None.

Comment on lines +259 to +269
assert not result
# - 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
assert item_c in tai.inventory
assert item_b in tai.inventory
assert item_a in tai.inventory
assert item_f in jesse.inventory
assert item_e in jesse.inventory
assert item_d 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!

Comment on lines 1 to 2
from multiprocessing import Condition
from unicodedata import category

Choose a reason for hiding this comment

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

A few more accidental VS Code imports.

Comment on lines 85 to 95
assert result is 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_a in tai.inventory
assert item_b in tai.inventory
assert item_c in tai.inventory
assert item_d in jesse.inventory
assert item_e in jesse.inventory
assert item_f in jesse.inventory

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 assertions, but I think there's a bug here. Your assertions say that tai and jesse still have the exact same items they started with. However, we want them to have swapped the best item by category.

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 changes and really nice implementation of swap_best_by_category!

Comment on lines 4 to 5
def __init__(self, category="Clothing", condition=0):
self.category = category
self.condition = condition
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__! Still consider my previous comment about why we might not want category to be an argument on the Clothing class.

@@ -21,7 +18,7 @@ def remove(self, item):
def get_by_category(self, category):
merch =[]
for item in self.inventory:
if item.category is category:
if item.category == category:

Choose a reason for hiding this comment

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

👍🏻

best_item = None
for item in self.get_by_category(category):
if best_item == None:
if best_item is None:

Choose a reason for hiding this comment

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

👍🏻

Comment on lines +58 to +65
my_best_item = self.get_best_by_category(their_priority)
their_best_item = other.get_best_by_category(my_priority)
if their_best_item is None or my_best_item is None:
return False
else:
self.swap_items(other, my_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 job! Really nice re-use of your earlier methods here. We don't need the else here, can you consider why?

Copy link
Author

Choose a reason for hiding this comment

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

Instead of using else I could just use another if statement. Since line 62 returns False, it exits the function. I realized that just now :)

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