Category: Project Review
-
BattleShip Part 11: Include columns and rows in display
Planning on wrapping this up by implementing one more feature around displaying the row and column labels. The project isn’t “perfect” but I feel like it’s in a good place (imo). Previously, I was only showing the coordinates and the statuses but not the labels. i.e. (A-J or 1-10). This made figuring out the coordinates…
-
BattleShip Part 10: Tests for Game Cli
Next, I’m going to add some unit tests for the GameCli class. The primary thing this class currently does is print output. To make testing a little easier, I’ll define a class that is in charge of printing instead of printing in the GameCli. It will be pretty simple and also control clearing the terminal…
-
BattleShip Part 9: Unit tests for Game class
Now that our Game class is mostly functional, we can add some unit tests. The first test I’ll write is just checking the game over functionality for a newly created game. Next, I’ll verify attacking all the ship coordinates results in a game over. You’ll notice, I redefined ship_coords and created a new game object.…
-
BattleShip Part 8: Addressing boundary issue
Running the project as-is, I noticed a problem with the output. There are 10 rows but only 9 columns. Also, my validation check is too strict because it only allows a single letter for the attack command. 1-9. So I’ll relax this to allow any numeric ending. This causes a new issue since now I…
-
BattleShip Part 7: Ship Placement Tests
While running the code, I did find a bug where ships could overlap. As I started trying to write a test for the ShipPlacer class, I found it was a little hard to do. There is a bunch of randomizing involved and because the primary thing that happens is updating the ship coordinate state, it…
-
BattleShip Part 6: Ship Placement
The next major part of the project involves randomly placing ships on a board. I decided to construct a new component that handles the placement of ships and builds a set of ship coordinates which is then used by the Game class.’ This component will be responsible for making sure ships are accurately placed on…
-
BattleShip Part 5: Game Mechanics
For the next part, I’m going to build out the game mechanics. I initially thought I might want some kind of Game and Board class. Where the GameCli would interact with the Game and the Game would control the Board. Now that I’m thinking a bit more about how I would want both of these…
-
BattleShip Part 4: Game Cli Test
One thing you usually want to do is add unit tests. Otherwise you have to basically constantly run your program and manually verify a bunch of scenarios. Having unit tests lets you saves time in the long run. The other benefit is that if something is really hard to unit test, then it could be…
-
BattleShip Part 2: Breaking out different components
The next thing I’d want to do is start thinking about breaking this project up into different components. Right now everything is all in one class. In this section, I will think about the different parts of this program and how they should be organized. Battle Ship Game I think some class that represents the…
-
BattleShip Part 1: Initial Review / Functional Requirements
Some initial observations. It is on Github which is nice and there’s a README that explains some basics. Probably don’t need to mention all the internal variables of BS in the README. BS is also not a great name it’s too non-descriptive. Before digging into the code, it’s important to understand how the project is…