Assignment#7:Battleship

This assignment makes students utilize basic programming skills to create a game of battleship. The code on lines 29-30 allows the user to know if they input the correct coordinates of the battleship.

battleship1

The code seen on lines 31-32 was added to notify the user if they didn’t guess the coordinates of the battleship.

battleship2

The “if” statement seen on lines 32-33 will tell the user the coordinates he/she guesses are not in the range of the coordinates.

battleship3

The “elif” statement on lines 34-35 in the following image will notify the user if they guessed the same coordinates more than once.

battleship4

The following image shows the game being tested for any kind of bugs.

battleship5

The code seen in this image added to lines 28-29 makes it so that the user has no more than 4 turns and it notifies the user on what turn he or she is currently on.

battleship6

To make sure the game is over after the user uses up all their turns without getting a correct answer, the code added on lines 42-43 is used to complete this task.

battleship7

A break was added on line 35 so the game will end when the user guessed the coordinates correctly.

battleship8

The following image displays a the code being run, as seen in the console(box in the upper right corner).

battleship9