Skip to content

MrBabylonian/battleship-with-java

Repository files navigation

Battleship: A Modern Take on a Classic Game

Introduction

Battleship, a timeless naval combat game, has captivated players for generations. This project aims to recreate the classic experience in a modern Java environment, combining strategic gameplay with clean code principles.

Key Features

  • Two-player mode: Engage in intense battles against a friend or opponent.
  • Strategic ship placement: Carefully position your ships to maximize their chances of survival.
  • Accurate hit detection: Experience the thrill of a well-placed shot and the disappointment of a miss.
  • Dynamic gameplay: Enjoy the tension and excitement as you navigate the battlefield.

Technologies Used

  • Java: The core language for implementing the game's logic and structure.
  • Object-oriented programming: A modular approach to organize the code and represent game entities.
  • Data structures: Arrays and lists are used to manage game data efficiently.
  • Input/output: The Scanner class is employed for user input, and the console is used for output.

Code Structure and Design

  • Clear separation of concerns: The code is divided into well-defined classes (e.g., Ship, Coordinate, GameField, Player, Game) to improve readability and maintainability.
  • Object-oriented principles: Encapsulation, inheritance, and polymorphism are used to create a flexible and extensible design.
  • Clean code practices: Adherence to coding conventions and best practices ensures code quality and maintainability.

Challenges and Solutions

  • Input validation: Implementing robust input validation to prevent errors and ensure a smooth user experience.
  • Hit detection: Developing an accurate algorithm to determine whether a shot has hit a ship.
  • Game flow management: Managing player turns, ship placement, and win conditions effectively.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages