Skip to content

project complete#90

Open
raeelwell wants to merge 1 commit into
Ada-C16:masterfrom
raeelwell:master
Open

project complete#90
raeelwell wants to merge 1 commit into
Ada-C16:masterfrom
raeelwell:master

Conversation

@raeelwell

Copy link
Copy Markdown

No description provided.

@beccaelenzil beccaelenzil 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.

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!

Comment thread swap_meet/decor.py

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good use of super()!

Comment thread swap_meet/item.py

def condition_description(self):
condition_statements = ["Terrible","Bad","OK","Good","Excellent"]
return condition_statements[self.condition-1] 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.

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 thread swap_meet/vendor.py
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

Copy link
Copy Markdown

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 thread swap_meet/vendor.py
Comment on lines +15 to +20
result = item
if item in self.inventory:
self.inventory.remove(result)
else:
return False
return 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.

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

Comment thread swap_meet/vendor.py
return None
max_value = 0
max_item_value = None
for item in items:

Copy link
Copy Markdown

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 thread swap_meet/vendor.py
Comment on lines +59 to +62
if my_swap and their_swap:
self.swap_items(other,my_swap,their_swap)
return True
return 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.

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 thread swap_meet/vendor.py
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

Copy link
Copy Markdown

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