Battleship - Full?

Am I misunderstanding the basic concept of fullness here?
I was under the impression that a board was considered full when it could no longer have any ships (a cap of 5).
Is that the case?

No, it is full when there are no more ‘nil’ values on the board

Don’t you see a little problem with that? The board gets populated until it’s full right? On a 10 by 10 board that means that a board is not going to be full until it’s loaded with ships. As in, a hundred ships.

I admit that it was strange that the full? method was being used when populating the board.
The full? method should be used when determining if the game is over.
The empty? method should be used when populating the board, not the full? method.
I think it was just a design error.

Hi!

The #full? method is in fact supposed to return a boolean that reflects whether every space on the board has a ship in it. Yes, @nordicwarrior, that does mean it would require 100 ships on a 10x10 board. Hopefully this doesn’t ever actually happen, because that would be a boring game of Battleship, but it’s important that we be able to implement a check for fullness before trying to place a ship so that we can avoid even trying to place a ship on a board that will never be able to receive a boat.

@sjdmlcjrcn, as with any object oriented programming problem, there are a lot of ways to model a game over state. The a/A solution delegates the #won method in the Battleship class to the #won? method in the Board class, which proceeds checks the board instance’s grid for the presence of un-torpedoed ships-- this is very similar logic to the #empty method in the Board class. I’m not sure how you’d use #empty when populating a board since you’d want to populate the board with more ships even if some ships are already on the board, but maybe you took #empty to be tracking stock of ships or something…

Lots of ways to build a program! More important than exactly modeling the a/A solution is understanding the entire spectrum of possibilities around building out object oriented methods and the trade offs between different choices.

Hope this helps, let us know if you have any further questions.

best,
-Shalin
Hacker in Residence, NYC

It answers one question two raises further questions such as why on God’s green earth would you design it that way? Why would you spec test for something so ridiculous?

And furthermore why was this not specified in the instructions? The implication of the instructions was that you populate the board until I can no longer take me shifts which means a maximum of ships that you can take in a standard game of Battleship. Nowhere in the instructions does it say fill it up until everything is a symbol of s