Skip to content

C22 - Wei Qiang (Sphinx) and Jen Nguyen (Phoenix)#8

Open
ItsJenOClock wants to merge 34 commits into
Ada-C22:mainfrom
hintow:main
Open

C22 - Wei Qiang (Sphinx) and Jen Nguyen (Phoenix)#8
ItsJenOClock wants to merge 34 commits into
Ada-C22:mainfrom
hintow:main

Conversation

@ItsJenOClock

Copy link
Copy Markdown

No description provided.

@yangashley yangashley left a comment

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 job on swap-meet, Wei and Jen!

I can see from the commit history that you made frequent commits, which is great!

Let me know if you have any questions about my comments.

Comment thread swap_meet/clothing.py
@@ -1,2 +1,10 @@
class Clothing:
pass No newline at end of file
from swap_meet.item import 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.

Nice work importing Item since we're using by name as the parent class of Clothing 👍

Comment thread swap_meet/clothing.py
Comment on lines +6 to +7
super().__init__(id, condition, age)
self.fabric = fabric

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 work on here!

On line 5 you correctly set the default value for fabric to "Unknown".

On line 6 you properly call the initializer of the parent, and pass along the values the child wants to use.

Lastly, good work remembering to refactor the function definition to include age so that it can get set from the subclasses.

Comment thread swap_meet/clothing.py
self.fabric = fabric

def __str__(self):
return f"{super().__str__()} It is made from {self.fabric} fabric."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👌 no notes

Comment thread swap_meet/item.py
def __str__(self):
return f"An object of type {self.get_category()} with id {self.id}."

def get_category(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.

Nice job writing this method in the super class and not repeating the logic in the sub classes 👍

Comment thread swap_meet/item.py
Comment on lines +21 to +25
if self.condition >= 4:
return "Excellent!"
if 2 <= self.condition < 4:
return "Good!"
return "Not the best!"

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 implementation works, but it could be considered brittle (prone to breaking) since the data relationships are encoded here (mapping a number to a string).

What data structures do you know of that could capture such an associative relationship like this? How about a dictionary with its key/value pairs?

ITEM_CONDITIONS = {
    0: "Not the best!", 
    ...
    4: "Excellent", ... 
}

return ITEMS_CONDITIONS.get(self.condition)

Having a clear representation of the data can make code easier to read and maintain than complex conditionals.

# ****** Complete Assert Portion of this test **********
# *********************************************************************
assert items == []
assert len(items) == 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The most specific assertion is on line 38 because it guarantees that the thing in items is actually a list that is empty. Therefore, we don't need the assertion on line 39 because we already know our list is empty

# - That the results is truthy
# - That tai and jesse's inventories are the correct length
# - 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 result

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of asserting that result is truthy, I'd use a more explicit boolean check so we know that the value referenced by result is True

Comment on lines +126 to +127
assert item_c not in tai.inventory
assert item_f not in jesse.inventory

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We can leave these two assertions off

# - That result is truthy
# - That tai and jesse's inventories are the correct length
# - That all the correct items are in tai and jesse's inventories, and that the items that were swapped are not there
assert result

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same comment as above about checking the actual value that is referenced by result. Many things could evaluate to a truthy value so being specific will test what we're actually interested in.

# - That result is falsy
# - That tai and jesse's inventories are the correct length
# - That all the correct items are in tai and jesse's inventories
assert not result

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same comment as above about actually checking the value of result instead of a falsey value.

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.

3 participants