Skip to content

CodecoolKRK20171/battleship-in-the-oo-way-55555

Repository files navigation

Battleship in the OOP way

The story

1. As users we would like to enter our names.
2. Enter ships on our 2 different boards.
3. Players will start randomly.
4. Enter positions of shooting:
    - if player miss, he lost his turn
    - if player hit the ship of opponent, he can try another shot
5. While player take down all parts of ship he get a message.
6. While player take all ships of his opponent, he give a   message about WIN!

Specification

main.py

square.py

Class Square

Attributes

  • is_marked Bool with starting False value.

  • shot Tuple of int, where player try hit the ship of opponent.

Instance methods

  • __init__(self, row, column, is_marked) Construct a piece of ship, and checking if player try shoot on this positions before.

  • life Check if player still have ships/squares on board.

  • is_marked Check if player try to hit in the same square of board

ship.py ###Class ship

Attributes

  • positions

    • positions x, y
  • squares

    • list of tuples positions of ships

Instance Methods

  • __init__(self, positions)

ocean.py

Class ocean

Attributes

  • ships list

  • board list

Instance methods

  • __init__(self, ships, board) Create an object is a game board.

  • fill_board Create a empty template, than fill it up with ships.

  • add_ship Take start position parameters and create ship.

player.py ###Class

Attributes

  • name Contain name of Players

Instance methods

  • put_ships_on_board Fill board with player ships

About

battleship-in-the-oo-way-55555 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages