-
Notifications
You must be signed in to change notification settings - Fork 598
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
Solution #470
base: master
Are you sure you want to change the base?
Solution #470
Conversation
app/main.py
Outdated
|
||
@classmethod | ||
def create_ship(cls, ship_cords: tuple) -> Ship: | ||
return Ship(*ship_cords) |
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.
use cls instead of Ship, it's the purpose of classmethod
app/main.py
Outdated
if isinstance(cell, Ship): | ||
return cell.get_deck(cords[0], cords[1]).symbol | ||
else: | ||
return cell.symbol |
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.
no need for else statement because if statement has return
app/main.py
Outdated
deck = self.get_deck(row, column) | ||
deck.is_alive = False | ||
deck.symbol = "*" | ||
return "Sunk!" if self.if_all_deck_is_damaged() else "Hit!" |
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.
a bit don't get it. In case deck is not found, get_deck returns None, but you set deck.is_alive = False anyway. Shouldn't it be missed?
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.
You're correct. The method get_deck cannot return None, as each ship consists solely of decks; thus, it will always return a deck. I've made some adjustments to ensure it functions more accurately.
Small changes:
Updated get_deck logic:
|
Added and implemented: