Java version of the game Battleship for CS 321: Intro to Object Oriented Programming Java.
Rules can be found below:
OBJECTIVE: Be the first to sink all 5 of your opponents ships! HOW TO PLAY: Secretly place your fleet of 5 ships on your OCEAN grid (the grid on the LEFTSIDE of the display). Your opponent does the same. Decide who will go first. You and your opponent will alternate turns, calling out one shot per turn to try and hit each other's ships.
SHIPS: Carrier(5 units) Battleship(4 units) Cruiser(3 units) Submarine(3 units) Destroyer(2 units) PLACE SHIP: - On the LEFTSIDE of the display is a column of 5 buttons, each corresponding to a ship - Select the desired ship by clicking on its representative button. - To place the selected ship, LEFT click on the start position of the ship, then RIGHT click on the end position of the ship (ex. selecting CARRIER then clicking A0 and A4 will place the Carrier vertically along the A column)
YOUR SHOT: On your turn, pick a target position on your TARGET grid (the grid on the RIGHTSIDE of the display). Each position has a letter-number coordinate that corersponds with the same coordinate on your opponent's ocean grid. To determine each coordinate, find its corresponding letter on the topside of the target grid and its number on the leftside of the target grid (the CENTER of the display)(ex. A9 corresponds to the lowest-left corner of the target grid) When you call a shot, your opponent must tell you whether your shot is a hit or a miss.
HIT: If you call out a shot location that is occupied by a ship on your opponent's ocean grid, your shot is a hit! Your opponent tells you which ship you have hit (cruiser, submarine, etc). Record your hit by placing a RED peg in the corresponding position on your TARGET grid (the grid on the RIGHTSIDE of the display). Your opponent places a RED peg in the corresponding position of the ship you have hit on his/her OCEAN grid (the grid on the LEFTSIDE of the display).
MISS: If you call out a shot location not occupied by a ship on your opponent's OCEAN grid, it's a miss. Record your miss by placing a WHITE peg in the corresponding position on your TARGET grid so you won't call this shot again. It's not neccessary for players to record each other's misses (but you can if you so desire)
PLACE PEG: - To place a RED peg, RIGHT click on a grid position - To place a WHITE peg, LEFT click on a grid position
SINKING A SHIP: Once all of the positions occupied by any one ship are hit, it has been sunk. The owner of the ship must announce which ship was sunk. Keep track of how many of your opponent's ships you sink by clicking on the representative button on the RIGHTSIDE of the display.
WINNING: If you're the first player to sink your opponent's entire fleet of 5 ships, you win the game!