-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: main
Are you sure you want to change the base?
Conversation
elif self._book_type == "Audio": | ||
return self.duration | ||
if self._book_type in self._booktype_duration.keys(): | ||
return self._booktype_duration[self._book_type] |
There was a problem hiding this comment.
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)): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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": |
There was a problem hiding this comment.
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...") |
There was a problem hiding this comment.
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.
There was a problem hiding this 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": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
We have changed some things in files "books","users" and "invoice".