Skip to content

Vivian Zhu, C18 Cheetahs#84

Open
viviantomato wants to merge 11 commits intoAda-C18:masterfrom
viviantomato:master
Open

Vivian Zhu, C18 Cheetahs#84
viviantomato wants to merge 11 commits intoAda-C18:masterfrom
viviantomato:master

Conversation

@viviantomato
Copy link

No description provided.

Copy link

@nancy-harris nancy-harris left a comment

Choose a reason for hiding this comment

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

Excellent job! There are comments below about how to better use parent classes. Please be sure to read that. For commits, it would be good if your commits were more descriptive. Instead of writing about which wave you completed, consider messages like "Created Item class" or "Added swap_items function to Vendor class".

pass No newline at end of file
from swap_meet.item import Item

class Clothing(Item):

Choose a reason for hiding this comment

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

Great start on adding Item as the parent class for Clothing! However, you are not fully using all of the things that parent classes offer. Rather than setting category and condition in the child class, you can send those values to the super class and it can be set there for you. You would use this line of code:

super().__init__("Clothing", condition)

and then you could remove lines 7 and 8. This works for Decor and Electronics as well!

Comment on lines +6 to +7
if category is None:
category = ""

Choose a reason for hiding this comment

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

You do not need to use None if the field is a string! Strings are immutable, so you can have the default be "". You want to use None for things that are mutable, like lists or dictionaries.

'''
if self.condition <= 1:
return "Uhhh"
elif self.condition <= 2 and self.condition >= 1:

Choose a reason for hiding this comment

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

Since you use elif, you can make your statements cleaner. For instance, you don't need to use >= 1 here because you know in order to get here the condition has to be higher than 1 because it skipped the first if.

# default value None is IMMUTABLE. MUTABLE type should not be used in DEFAULT argument.

# Wave 1
def __init__(self, inventory = None):

Choose a reason for hiding this comment

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

Excellent!

inventory = []
self.inventory = inventory

def add(self, add_item):

Choose a reason for hiding this comment

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

Excellent!

Comment on lines +38 to +40
assert item_a not in items
assert item_b not in items
assert item_c not in items No newline at end of file

Choose a reason for hiding this comment

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

Great asserts! These three are actually not needed. Since the first assert tells us that there is nothing in the list, we don't need to check if these individual items are in the list.

Comment on lines +79 to +87
assert result == True
assert len(tai.inventory) == 3
assert len(jesse.inventory) == 3
assert item_a in tai.inventory
assert item_b in tai.inventory
assert item_c in jesse.inventory
assert item_f in tai.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.

Excellent!

Comment on lines +114 to +122
assert result == True
assert len(tai.inventory) == 3
assert len(jesse.inventory) == 3
assert item_a in tai.inventory
assert item_b in tai.inventory
assert item_f in tai.inventory
assert item_d in jesse.inventory
assert item_e in jesse.inventory
assert item_c in jesse.inventory

Choose a reason for hiding this comment

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

Excellent!

Comment on lines +200 to +208
assert not result
assert len(tai.inventory) == 3
assert len(jesse.inventory) == 3
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.

Excellent!

Comment on lines +234 to +242
assert not result
assert len(tai.inventory) == 3
assert len(jesse.inventory) == 3
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.

Excellent!

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