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

Puja Mukherjee-Lions #82

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

Puja Mukherjee-Lions #82

wants to merge 37 commits into from

Conversation

PujaMukh
Copy link

@PujaMukh PujaMukh commented Oct 7, 2022

This project helped me learn more about classes and inheritance. Really enjoyed it!

… changed parameters of first part of Wave 1 from list to if and None
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 Puja! I love seeing the extra functionality you added and your frequent commits! This project is green.

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

Choose a reason for hiding this comment

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

Nice use of super! Here, it would be a good idea to not have category be a parameter in the Clothing constructor. We know that we always want category to be "Clothing", so we shouldn't give the caller the illusion that they can change it.

Also a small style note: when using default/named parameters, do not put spaces before or after the equals sign. It should instead look like this:
condition=0.

Comment on lines +8 to +14
return "The finest clothing you could wear."





Choose a reason for hiding this comment

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

Please delete empty lines at the end of your file.

Comment on lines +12 to +16
condition_descriptions = ["I dont like zero", "I dont like one either",
"Maybe I like two", "Hmmmm.....probably three is nice", "I like four",
"Five is a nice number"]
return condition_descriptions[self.condition]

Choose a reason for hiding this comment

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

This works if the condition is an integer, but what would happen if it were a float? (Some of the test data shows the condition as 3.5. How could you change this method to accommodate that?

Comment on lines 0 to 16
class Vendor:
pass No newline at end of file
MAX_AGE = 1000
# Wave 1
def __init__(self, inventory = None):
if inventory is None:
inventory = []
self.inventory = inventory
def add(self,item):
self.inventory.append(item)
return item
def remove(self,item):
for inventory_item in self.inventory:
if inventory_item == item:
self.inventory.remove(item)
return item
return False

Choose a reason for hiding this comment

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

Great logic! Stylistically, please add an empty line between functions/methods.

MAX_AGE = 1000

Choose a reason for hiding this comment

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

What would happen if we had a dinosaur fossil that was more than a thousand years old? To accommodate this case, we can set our max age to infinity using float('inf'). We can also consider doing this in the method itself instead of having a constant attached to our Vendor. The constant is just an implementation detail that helps us find the youngest object, it's not something that we need to expose to other parts of out code. I really like the idea of using a constant though!

Comment on lines +61 to +66
my_best_item = self.get_best_by_category(their_priority)
their_best_item = other.get_best_by_category(my_priority)
if my_best_item == None or their_best_item == None:
return False
return self.swap_items(other, my_best_item, their_best_item)

Choose a reason for hiding this comment

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

Really nice use of helpers! Small note, please use is None instead of == None.

Comment on lines +79 to +82
vendor_newest_item = self.find_newest_item()
friend_newest_item = friend_vendor.find_newest_item()
return self.swap_items(friend_vendor, vendor_newest_item, friend_newest_item)

Choose a reason for hiding this comment

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

Great extra functionality!

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

Choose a reason for hiding this comment

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

This works, but we can make it simpler by removing lines 38-40. If the length of items is 0, we know that none of our items can be present in it.

Comment on lines +99 to +102
assert (item_f in tai.inventory) == True
assert (item_c not in tai.inventory) == True
assert (item_c in jesse.inventory) == True
assert (item_f not in jesse.inventory) == True

Choose a reason for hiding this comment

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

We don't need the == True here. asserts automatically succeed when given a truthy value and automatically fail when given a falsey value.

Comment on lines +311 to +340
def test_swap_by_newest_returns_True():
# Arrange
item_a = Item(age = 5)
item_b = Item(age = 1)
item_c = Item(age = 13)
fatimah = Vendor(
inventory=[item_a, item_b, item_c]
)

item_d = Item(age = 6)
item_e = Item(age = 2)
jolie = Vendor(
inventory=[item_d, item_e]
)
# Act

result = fatimah.swap_items(jolie, item_b, item_e)

# Assert

assert len(fatimah.inventory) == 3
assert item_b not in fatimah.inventory
assert item_a in fatimah.inventory
assert item_c in fatimah.inventory
assert item_e in fatimah.inventory
assert len(jolie.inventory) == 2
assert item_e not in jolie.inventory
assert item_d in jolie.inventory
assert item_b in jolie.inventory
assert result

Choose a reason for hiding this comment

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

Love seeing the new test!

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