Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. class Board:
  2.     def __init__(self, board_height, board_width, board, x, y):
  3.         self._validate_board(board_height, board_width)
  4.         self._board_height = board_height
  5.         self._board_width = board_width
  6.         self._x = x
  7.         self._y = y
  8.         self._board = board
  9.     @staticmethod
  10.     def board_bounds():
  11.         board_height = int(input("Give the height of a board in range of 4-9: "))
  12.         board_width = int(input("Give the width of a board in range of 4-9: "))
  13.         return board_width, board_height
  14.  
  15.     def _validate_board(self, board_height, board_width):
  16.         if board_height <= 3 or board_height >= 10 or board_width <= 3 or board_width >= 10:
  17.             raise ValueError("Your values don't meet the requested vale ranges, try again")
  18.  
  19.     def check_sink(self, board, x, y):
  20.         if board[x][y] == "A":
  21.             ship = "Aircraft Carrier"
  22.         elif board[x][y] == "B":
  23.             ship = "Battleship"
  24.         elif board[x][y] == "S":
  25.             ship = "Submarine"
  26.         elif board[x][y] == "D":
  27.             ship = "Destroyer"
  28.         elif board[x][y] == "P":
  29.             ship = "Patrol Boat"
  30.  
  31.         board[-1][ship] -= 1
  32.         if board[-1][ship] == 0:
  33.             print(ship + " Sunk")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement