Potential for battleship walkthrough?

I’m just wondering if it’s possible to walk through the battleship game with a TA or even someone else who feels really confident about it. I’m struggling to really internalize what exactly is going on in this problem and would love some help.

If a walkthrough isn’t possible, would anyone be able to answer a whole bunch of questions that I have in DMs?

Hi Laurette, we would be happy to answer your questions. Can you please post them here on this thread so other students can also see them?


@ommish Thanks for responding! So I went thru it a few more times and some things did become more clear so that’s good, but here are some outstanding questions:

  1. What is the benefit of system("clear") ? I realize that it’s supposed to force the display to the top of the console, but it does look a little awkward in practice.

  2. Why does the play_turn method kick the user out of the game entirely if they double-click enter? Is there a way to prevent that from happening?

  3. When is the prompt method in the player class ever used? Was this an oversight or am I missing something there?

  4. (definitely the most pressing) Do we have solutions available for the bonus features? I’m feeling pretty lost on where to start with those and it always helps me to move backwards and repeat until I totally get it. I’d really love some help with that.

Thanks so much!

Hi Laurette,

  1. system("clear") is in fact a bit awkward, but it’s the best thing we can do in the console. Fortunately, we’ll eventually be writing browser games where we have much better solutions.

  2. The game is currently set up so that it doesn’t catch an invalid input. When you press enter twice, then it will process the second press as an empty input, which is invalid. That’s why the game breaks at that point. I encourage you to try to write a method that validates the input before it processes it so that you don’t get an error that breaks the game.

  3. Good catch! This must be an oversight. The prompt method should be used in play_turn inside the until loop.

  4. We don’t have solutions for the bonus features. The bonus features are supposed to really challenge you; they’re where we want to see your implementation, as opposed to the earlier parts, where we want you to implement things in a specific ways. If you understand everything leading up to the bonus features, then you’re in really good shape for the course. Pushing yourself as much as you can to do the bonus features is meant to solidify your knowledge.

@m1010j Thanks for your quick response! That’s definitely a relief, thought I was really behind in terms of the bonus questions.