3.3.6 Battleships Move Codehs __exclusive__ Jun 2026
The heart of this program is the Ship class. You need a constructor to initialize the ship's state.
Have a different version of the exercise or need help with a specific error? Leave a comment below or consult the CodeHS discussion forum for this module.
To solve 3.3.6, you must think like an architect. You aren't just writing one long script; you are designing a system. The CodeHS environment usually provides a setup where you work with a Grid object and a Ship object. 3.3.6 battleships move codehs
Before moving the ship, check if the new position is inside the grid. If it is not, do not update the coordinates.
Treating "up" as increasing the column index. Why it fails: In most grid representations, row 0 is the top, so "up" should decrease the row number. Fix: Draw a small grid on paper and trace your logic. The heart of this program is the Ship class
If you share the exact or language (JS/Python) from your CodeHS assignment, I can give you a more precise, copy-paste-ready solution.
The exercise on CodeHS is more than just a tedious assignment—it is your introduction to stateful game logic. By implementing boundary checks and directional movement, you are building the foundation for every grid-based game, from Chess to Pac-Man. Leave a comment below or consult the CodeHS
: Beginners often write if (safeToMove == true) . While this works, it is redundant. Since safeToMove is already a boolean, if (safeToMove) is the cleaner, professional way to write it.