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

Group 5: Pullrequest for refactoring excersice Day2 #13

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

Conversation

SeverinBeger
Copy link
Collaborator

@SeverinBeger SeverinBeger commented Nov 23, 2023

We have changed some things in files "books","users" and "invoice".

@dejavu9127 dejavu9127 self-assigned this Nov 23, 2023
@denishoornaert denishoornaert self-assigned this Nov 23, 2023
elif self._book_type == "Audio":
return self.duration
if self._book_type in self._booktype_duration.keys():
return self._booktype_duration[self._book_type]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dict?

@staticmethod
def find_book(self,book_copy: "BookCopy") -> "Book":
for book in self.Books.Book:
if(book.__eq__(book,book_copy)):
Copy link
Collaborator

@denishoornaert denishoornaert Nov 23, 2023

Choose a reason for hiding this comment

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

discount_count: int = max(0, len(self.books) - self.min_books_for_discount)
discount: float = discount_count * self.discount_per_book
discount += current_reading_credits * self.discount_per_reading_credit
final_price = price - discount
Copy link
Collaborator

@denishoornaert denishoornaert Nov 23, 2023

Choose a reason for hiding this comment

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

Nice but could be broken down even further (e.g., dedicated function/method) :)

borrowed_book.existing_items,
borrowed_book.borrowed_items,
borrowed_book._book_type
borrowed_book.genres
)
return book

def can_borrow(self) -> bool:
if self._book_type == "Paper":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not a dict here? Seems like a mix of if-else statements and dict lookups.

elif self._book_type == "Audio":
return 2
if(self._book_type in self._booktype_fee.keys()):
return self._booktype_fee[self._book_type]
else:
raise AttributeError("No such book type...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Redundant, no? A failed dict lookup will raise a KeyError. Maybe you can let it propagate.

Copy link

@dejavu9127 dejavu9127 left a comment

Choose a reason for hiding this comment

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

Good idea to use dict of functions, maybe define as lambda with pages as input

@@ -155,3 +156,10 @@ def delete_invoice(invoice: Invoice):
index = invoices.index(invoice)
if index >= 0:
invoices.remove(invoice)

@staticmethod
def find_book(self,book_copy: "BookCopy") -> "Book":

Choose a reason for hiding this comment

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

Suggested change
def find_book(self,book_copy: "BookCopy") -> "Book":
def find_book(self,book_copy: "BookCopy") -> "Book":

Not sure if you can pass self as input argument to static method. Maybe Maintain an Inventory class, and pass as input arg

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