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

project complete #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

project complete #90

wants to merge 1 commit into from

Conversation

raeelwell
Copy link

No description provided.

Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

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

Great work on your first OOP project. It is clear that the learning goals around defining classes with instance variables and methods and using inheritance were met. Your code is clear and logical, and you've made good use of helper functions. I've left a few comments on ways you might consider refactoring. In particular, I've noted how you could use a pattern of checking for an edge case and then moving the main logic of the function outside a conditional to enhance readability. With regards to git, it would be good to practice making commits throughout the project. You can use a commit after completing each wave as a rule of thumb. When you submit the project, name your pull request "Cedar- Rae". Overall, nice work!


class Decor(Item):
def __init__(self, condition = 0):
super().__init__(category = "Decor", condition = condition)

Choose a reason for hiding this comment

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

Good use of super()!


def condition_description(self):
condition_statements = ["Terrible","Bad","OK","Good","Excellent"]
return condition_statements[self.condition-1]

Choose a reason for hiding this comment

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

Per our discussion in class, you can use round or int for this method to work for float values of condition. Otherwise, nice appraoch!

Comment on lines +30 to +34
if not self.remove(my_item):
return False
if not friend.remove(their_item):
self.add(my_item)
return False

Choose a reason for hiding this comment

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

Consider including this in one compound conditional to enhance readability.

Suggested change
if not self.remove(my_item):
return False
if not friend.remove(their_item):
self.add(my_item)
return False
if not self.remove(my_item) or not friend.remove(their_item):
return False

Comment on lines +15 to +20
result = item
if item in self.inventory:
self.inventory.remove(result)
else:
return False
return result

Choose a reason for hiding this comment

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

Consider first testing for the edge case, and then moving the main functionality of your function outside the if/else. This programming pattern is called a guard clause and can among other things enhance the readability of your code.

Suggested change
result = item
if item in self.inventory:
self.inventory.remove(result)
else:
return False
return result
if item not in self.inventory:
return False
self.inventory.remove(result)
return item

In addition, assigning result = item means we need to take a step to understand what result is. Consider simply returning item

return None
max_value = 0
max_item_value = None
for item in items:

Choose a reason for hiding this comment

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

Great work implementing this max algorithm

Comment on lines +59 to +62
if my_swap and their_swap:
self.swap_items(other,my_swap,their_swap)
return True
return False

Choose a reason for hiding this comment

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

For consistency, and to remove logic from an ident, consider refactoring in the following way:

Suggested change
if my_swap and their_swap:
self.swap_items(other,my_swap,their_swap)
return True
return False
if my_swap and their_swap:
return False
self.swap_items(other,my_swap,their_swap)
return True

Comment on lines +48 to +53
max_value = 0
max_item_value = None
for item in items:
if item.condition > max_value:
max_value = item.condition
max_item_value = item

Choose a reason for hiding this comment

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

Suggested change
max_value = 0
max_item_value = None
for item in items:
if item.condition > max_value:
max_value = item.condition
max_item_value = item
max_item = items[0]
for item in items:
if item.condition > max_item.condition:
max_item = item

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