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 #524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VolodymyrPovroznyk
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on implementing the Battleship game! 🎉 Your code meets the task requirements and constraints effectively. While there are some areas for improvement, such as adding validation for input coordinates and making the ship configuration more flexible, these are minor and do not impact the core functionality. Keep up the good work, and consider these enhancements for future projects to make your code even more robust and adaptable. Happy coding! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

@@ -1,34 +1,150 @@
class Deck:
def __init__(self, row, column, is_alive=True):
pass
def __init__(self, row: int, column: int, is_alive: bool = True) -> None:

Choose a reason for hiding this comment

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

Consider adding validation for the row and column parameters to ensure they are within acceptable ranges (e.g., 0 to 9 for a 10x10 grid). This will prevent invalid deck positions.

Comment on lines +11 to +12
start: tuple[int, int],
end: tuple[int, int],

Choose a reason for hiding this comment

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

It would be beneficial to validate the start and end coordinates to ensure they form a valid ship (either horizontal or vertical, and within bounds).

# If it is, then it should check if this cell is the last alive
# in the ship or not.
pass
def __init__(self, ships: list[tuple[tuple]]) -> None:

Choose a reason for hiding this comment

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

The constructor for Battleship assumes a specific format for the ships parameter. Consider adding validation to ensure the input matches the expected format.


def _validate_field(self) -> bool:
ships = list(set(self.field.values()))
if len(ships) != 10:

Choose a reason for hiding this comment

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

The _validate_field method assumes a fixed number of ships and decks. If you plan to support different configurations, consider making these values configurable.

Copy link

@vsmutok vsmutok left a comment

Choose a reason for hiding this comment

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

Great!

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