Skip to content

LukeWardle/BattleshipLite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BattleshipLite Project

This is a console-based 2-player game that is based on the popular board game Battleship from Mattel. The game involves a 25-spot grid ranging from A1 - E5, where each player will place 5 pegs on the board to represent their 5 ships. Players will take turns firing at their opponents’ ships, and the first person to sink all 5 ships wins.

How to Play

  1. 1.Two players open the console.
  2. 2.Ask user 1 for where to place their ships.
  3. 3.Ask user 2 for where to place their ships.
  4. 4.Ask user 1 for a shot.
  5. 5.Determine hit or miss.
  6. 6.Determine if the games is over.
  7. 7.Ask user 2 for a shot.
  8. 8.Determine hit or miss.
  9. 9.Determine if the game is over.
  10. 10.Repeat until someone wins.
  11. 11.Identify who the winner is.
  12. 12.Exit the application.

Additional Requirements

The game is played on the same console. The other player does not get one last chance after being sunk. Only one ship can be placed per spot. A player cannot shoot the same spot twice. A visual of the grid is shown. The game data is not stored. The number of players may be changed in the future. A computer player may be added in the future.

UI Design

Display a welcome message. Ask user 1 for their name. Ask user 1 for their 5 ship placements. Ask for placement. Determine if it was valid. Store. Clear. Ask user 2 for their name. Ask user 2 for their ship placements. Ask for placement. Determine if it was valid. Store. Clear. Display grid of where user 1 has fired. Ask user 1: Where would you like to fire on? Verify a valid spot. Check results. Store shot. Clear. Display the score (user1:2 ships left, user 2: 4 ships left). Repeat with user 2. Loop until someone wins. Print winners name and number of shots taken. Wait for user to say they are done.

Logic Design

Clear Display Method: Asking for name. Method: Get ship placement. Method: Determine if valid spot for ship. Storing ship information: List per user? Storing shot information: List per user? Method: Create the grid for the user. Method: Print out grid. Method: Fire on Opponent. Method: Determine if a shot can be taken & outcome. Method: Display score. Method: Print winner and shots taken. Data Design User’s name – string. User’s ship locations – List. User’s shot grid – List.

Authors

Luke Wardle - l.wardle@live.co.uk

Battleship Lite Application Plannign Notes.docx

About

BattleshipLite game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages