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

Ruby - Ruth M #75

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open

Ruby - Ruth M #75

wants to merge 32 commits into from

Conversation

rmora101
Copy link

@rmora101 rmora101 commented Apr 7, 2023

No description provided.

Copy link

@mmcknett-ada mmcknett-ada left a comment

Choose a reason for hiding this comment

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

Yellow 🟡. As you know, wave 6 isn't complete, but everything else looks great!

You're almost there with Wave 6, too! get_best_by_category just needs some tweaks to get working, then you can use that and swap_items to finish off swap_best_by_category. You're not required to resubmit, but if you are looking for practice later, I recommend coming back to this!

@@ -2,7 +2,7 @@
from swap_meet.vendor import Vendor
from swap_meet.item import Item

@pytest.mark.skip
# @pytest.mark.skip

Choose a reason for hiding this comment

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

[nit] you can remove these

if self.condition == 0:
return 'this is Garbage!'
elif 1 <= self.condition < 2:

Choose a reason for hiding this comment

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

Careful about statements like this. They sometimes have unexpected behavior. Prefer writing out the logical expression:

elif 1 <= self.condition and self.condition < 2:

Also, worth noting: what happens if self.condition is between 0 and 1?

Comment on lines +7 to +9
id = int(uuid.uuid4())
self.id = id

Choose a reason for hiding this comment

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

A ternary is also fine here:

        self.id = id if id else uuid.uuid4().int

Comment on lines +46 to +52

self.add(other_vendor.inventory[0])

self.remove(self.inventory[0])

other_vendor.remove(other_vendor.inventory[0])

Choose a reason for hiding this comment

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

[nit] No need to space between each function call

Comment on lines +60 to +66

for stuff in self.inventory:
if stuff.get_category() == category:
objects.append(stuff)

return objects

Choose a reason for hiding this comment

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

Notice this pattern of:

result_list = []
for element in source_list:
    if some_condition(element):
        result_list.append(element)

can be rewritten using a list comprehension as:

result_list = [element for element in source_list if some_condition(element)]

Which here would look like:

objects = [stuff for stuff in self.inventory if stuff.get_category() == category]
return objects

At first, this may seem more difficult to read, but comprehensions are a very common python style, so I encourage y’all to try working with them!

def get_by_category(self,category):

self.category = category

Choose a reason for hiding this comment

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

Careful here! It's probably unexpected if calling a get function modifies the instance object. Nothing is wrong with the class as-is because you don't use self.category in any other method. If you did use it elsewhere, this could have unintended side effects.

Comment on lines +74 to +76
if stuff.condition_description() < best_condition:
best_condition = category_condition

Choose a reason for hiding this comment

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

You're on the right track! Some things to think about...

  1. You want to get the things from the self.inventory that have a specific category_condition. You wrote a method above this that can do that!
  2. Your "best" condition is the highest one, not the lowest
  3. You want to keep track of the best condition and the best stuff you've seen, too.

With those things in mind, see if you can come up with how to modify this code. If you still get stuck, here's a snippet that I think might help get you there: https://gist.github.com/mmcknett-ada/26444ed29c91927c05dc7d577d5bd67e

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