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

'Solution' #309

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

'Solution' #309

wants to merge 3 commits into from

Conversation

jinjo0222988
Copy link

No description provided.

app/main.py Outdated
self.is_drowned = is_drowned
self.decks = Ship.create_decks(start, end)

def get_deck(self, row: int, column: int) -> Deck:

Choose a reason for hiding this comment

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

It can also return None

Choose a reason for hiding this comment

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

not fixed

app/main.py Outdated
Comment on lines 33 to 36
self.is_drowned = True
for deck in self.decks:
if deck.is_alive:
self.is_drowned = False

Choose a reason for hiding this comment

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

Just use any/all

app/main.py Outdated
Comment on lines 44 to 56
if ship_begin == ship_end:
return [Deck(*ship_begin)]

def fire(self, row, column):
# Change the `is_alive` status of the deck
# And update the `is_drowned` value if it's needed
pass
border = 0
if ship_begin[1] != ship_end[1]:
border = 1

ship_decks = [Deck(ship_begin[0], ship_begin[1])]
blank_deck = [ship_begin[0], ship_begin[1]]

while blank_deck[border] != ship_end[border]:
blank_deck[border] += 1
ship_decks.append(Deck(blank_deck[0], blank_deck[1]))

Choose a reason for hiding this comment

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

Instead of if+ while just use forloop into forloop

app/main.py Outdated
Comment on lines 76 to 77
else:
return "Miss!"

Choose a reason for hiding this comment

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

Suggested change
else:
return "Miss!"
return "Miss!"

app/main.py Outdated
self.is_drowned = is_drowned
self.decks = Ship.create_decks(start, end)

def get_deck(self, row: int, column: int) -> Deck:

Choose a reason for hiding this comment

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

not fixed

app/main.py Outdated
Comment on lines 41 to 42
if ship_begin == ship_end:
return [Deck(*ship_begin)]

Choose a reason for hiding this comment

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

This check is redundant

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