Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Board:
- def __init__(self, board_height, board_width, board, x, y):
- self._validate_board(board_height, board_width)
- self._board_height = board_height
- self._board_width = board_width
- self._x = x
- self._y = y
- self._board = board
- @staticmethod
- def board_bounds():
- board_height = int(input("Give the height of a board in range of 4-9: "))
- board_width = int(input("Give the width of a board in range of 4-9: "))
- return board_width, board_height
- def _validate_board(self, board_height, board_width):
- if board_height <= 3 or board_height >= 10 or board_width <= 3 or board_width >= 10:
- raise ValueError("Your values don't meet the requested vale ranges, try again")
- def check_sink(self, board, x, y):
- if board[x][y] == "A":
- ship = "Aircraft Carrier"
- elif board[x][y] == "B":
- ship = "Battleship"
- elif board[x][y] == "S":
- ship = "Submarine"
- elif board[x][y] == "D":
- ship = "Destroyer"
- elif board[x][y] == "P":
- ship = "Patrol Boat"
- board[-1][ship] -= 1
- if board[-1][ship] == 0:
- print(ship + " Sunk")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement