Skip to content

Sphinx_Olga_Karaivanska_and_Tatiana_Snook#11

Open
lioliadoc wants to merge 22 commits intoAda-C22:mainfrom
lioliadoc:main
Open

Sphinx_Olga_Karaivanska_and_Tatiana_Snook#11
lioliadoc wants to merge 22 commits intoAda-C22:mainfrom
lioliadoc:main

Conversation

@lioliadoc
Copy link
Copy Markdown

No description provided.

Comment thread swap_meet/item.py
Comment on lines 2 to +12
class Item:
pass No newline at end of file
def __init__(self, id=None, condition=0):
self.id = id if id is not None else uuid.uuid4().int
self.condition = condition

def get_category(self):
return self.__class__.__name__

def __str__(self):
return f"An object of type {self.get_category()} with id {self.id}."
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Really great work on the inheritance and methods for the different classes!

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

conditions = {0: "New", 1: "Mint", 2: "Good", 3: "Fair", 4: "Heavily used", 5: "Damaged"}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would opt to move this inside of the condition_description method since it is the only function that will use it. This could also be a time to use match case!

    def condition_description(self):
        match self.condition:
            case 0:
                return "Throw Away"
            case 1:
                return "Eh"
            case 2:
                return "Better..."
            case 3:
                return "..."
            case 4: 
                return "Okay?!"
            case 5:
                return "Yes!"

Comment thread swap_meet/vendor.py
class Vendor:
pass No newline at end of file
def __init__(self, inventory=None):
self.inventory = [] if inventory is None else 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.

Comment thread swap_meet/vendor.py
return None

def swap_items(self, other_vendor, my_item, their_item):
if my_item not in self.inventory or their_item not in other_vendor.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 could also use get_by_id to check if an item is in a given inventory and then check to see if that function returns None or the item.

Comment thread swap_meet/vendor.py
Comment on lines +28 to +31
self.remove(my_item)
other_vendor.add(my_item)
other_vendor.remove(their_item)
self.add(their_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.

Comment thread swap_meet/vendor.py
Comment on lines +38 to +42
first_item = self.remove(self.inventory[0])
other_vendor.add(first_item)

other_first_item = other_vendor.remove(other_vendor.inventory[0])
self.add(other_first_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.

Couldn't we also use the the swap_items method here to do this?

Comment thread swap_meet/vendor.py
Comment on lines +49 to +51
for item in self.inventory:
if item.get_category() == category:
category_list.append(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.

How would this look as list comprehension?

Comment thread swap_meet/vendor.py
best_item = None
highest_condition = 0

for item in self.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.

Here we could loop over a list of items in a specific category curated by get_by_category. That way we don't have to check to see if an item has a matching category.

Comment thread swap_meet/vendor.py
Comment on lines +66 to +74
def swap_best_by_category(self, other_vendor, my_priority, their_priority):
my_best_item = self.get_best_by_category(their_priority)
their_best_item = other_vendor.get_best_by_category(my_priority)

if my_best_item and their_best_item:
self.swap_items(other_vendor, my_best_item, their_best_item)
return True

return False No newline at end of file
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! Great work!

Comment on lines +51 to +53
assert len(vendor.inventory) == 3
assert item not in vendor.inventory
assert result == False
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, this accurately tests for everything!

Comment on lines +135 to +136
assert len(jolie.inventory) == 0
assert len(fatimah.inventory) == 3
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How could we alter these to ensure that test for the correct data structures as well? Right now they would pass with any data structure of length 0 and 3.

Comment on lines +125 to +130
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
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 could use a loop here to help DRY up our code

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