Skip to content

Solution#656

Open
saulorodrigocfs wants to merge 3 commits intomate-academy:masterfrom
saulorodrigocfs:develop
Open

Solution#656
saulorodrigocfs wants to merge 3 commits intomate-academy:masterfrom
saulorodrigocfs:develop

Conversation

@saulorodrigocfs
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.

Review Summary

I am requesting changes because there are a few critical issues that can break functionality or violate the task’s core requirements. First, in Battleship.fire (app/main.py), there is a redundant else after an early return (the if ship.is_drowned: return "Sunk!" else: ... branch), which explicitly violates the checklist rule against redundant else after a non-empty return [CHECKLIST ITEM #3]; you should remove the else and return "Hit!" directly. Second, in Ship.__init__ (app/main.py), if start and end coordinates are not strictly horizontal or vertical, none of the if/elif branches execute and self.decks is never set, which will cause an AttributeError later; add an orientation check and raise a clear ValueError("Ship must be horizontal or vertical") for invalid or diagonal ships. Third, there is currently no validation that ship coordinates lie within the required 10x10 board (rows and columns 0..9); you should validate these coordinates (either in Ship.__init__ or in Battleship.__init__) and raise an error on out-of-range values so the field truly matches the problem specification. These three points are all critical: they can either cause runtime errors or break explicit problem and checklist requirements, so they must be addressed before this solution is considered complete. Once you add the orientation and bounds checks and clean up the redundant else, the rest of your model and firing logic looks solid and will satisfy the core behavior described in the task.


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Review Summary

I am approving your solution because the core Battleship requirements are correctly implemented: the Battleship class is present, __init__(self, ships) builds the 10x10 field, and fire(self, location) returns the correct strings ("Miss!", "Hit!", "Sunk!") with proper bounds and orientation validation. This means the main functional contract of the task is satisfied and there are no critical blockers preventing correct usage.

The main functional gap is that overlapping ships are not detected when building the field; in a more robust version you should check before assigning each deck that the cell is still empty and raise an error if it is not, to avoid silent overwrites. Additionally, the optional extras (print_field and a _validate_field method to verify ship counts and adjacency rules) are not implemented; these are not required for passing but would improve debuggability and rule enforcement. As a minor improvement, you might also document or explicitly handle what happens when a player fires multiple times at the same cell so future readers know that behavior is intentional. Overall, the core logic is solid and clean, and you are in a good position to extend it with the optional validation and debugging helpers if you choose.


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

Footnotes

  1. Rate AI review example

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.

2 participants