Skip to content

Advanced-Programming-1403/PaperBattleship

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“„πŸ›³οΈ Paper Battleship

Paper Battleship is a Java-based networked version of the classic Battleship game, built using socket programming. It simulates the nostalgic feel of the paper-based game, now with two players connecting over a network and taking turns to attack each other's grid.

🎯 Features

  • Two-player turn-based gameplay over a network
  • Server-client architecture using Java Sockets
  • Console-based grid interaction
  • Hit/miss feedback and ship sinking notification
  • Simple and minimalistic design for learning and fun

πŸ”§ Objective

The core game logic is already implemented, but you are free to modify or extend it as needed. Your main tasks are to:

  • Complete the TODOs in the code
  • Set up the network connection
  • (Optionally) Improve or change the existing game logic
  • (Optionally) Changing the network handling logic
  • (Optionally) Considering use of JSON for message format and implementing better connection management between server and socket

πŸ•ΉοΈ How to Play

  1. Start the Server Run the BattleShipServer on one machine (or the host machine).

  2. Connect Two Clients Run BattleShipClient on two separate terminals or machines. Each player enters the server's IP and port to connect.

  3. Gameplay

    • Each player places their ships (can be manual or random depending on your implementation).
    • Players take turns entering grid coordinates like A3, B7, etc.
    • The game continues until one player sinks all of the opponent’s ships.

image

πŸš€ Getting Started

Prerequisites

  • Java 8 or higher
  • Terminal or IDE (e.g., IntelliJ, Eclipse)

πŸ“ Project Structure

PaperBattleShip/
β”œβ”€β”€ java/
β”‚   β”œβ”€β”€ Client/
β”‚   β”‚   β”œβ”€β”€ BattleShip.java
β”‚   β”‚   β”œβ”€β”€ BattleShipCell.java
β”‚   β”‚   β”œβ”€β”€ BattleShipClient.java
β”‚   β”‚   β”œβ”€β”€ BattleShipClientNetworkHandler.java
β”‚   β”‚   └── utils/
β”‚   β”‚       └── AnsiColor.java
β”‚   └── Server/
β”‚       β”œβ”€β”€ BattleShipServer.java
β”‚       └── ClientHandler.java

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages