-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathship.py
More file actions
25 lines (20 loc) · 868 Bytes
/
Copy pathship.py
File metadata and controls
25 lines (20 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from box import Box
class Ship(Box):
ships = {'Carrier': 5, 'Battleship': 4, 'Cruiser': 3, 'Submarine': 3, 'Destroyer': 2}
def __init__(self, board, coordinates, name):
self.sunk_coordinates = []
self.coordinates = []
self.initialize_coordinates(board, coordinates)
self.change_boxes_to_ship()
self.name = name
def change_boxes_to_ship(self):
"""Change the boxes from '.' to '@'."""
for box in self.coordinates:
box.change_to_ship()
def initialize_coordinates(self, board, coordinates):
"""Append all the box objects to a list named 'coordinates'"""
for coordinate in coordinates:
self.coordinates.append(board.find_coordinate(coordinate))
def change_boxes_to_sunk(self):
for box in self.sunk_coordinates:
box.change_to_sunk()