-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshipyard.py
More file actions
76 lines (53 loc) · 1.22 KB
/
shipyard.py
File metadata and controls
76 lines (53 loc) · 1.22 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
Created on 26/04/2016
@author: bruno.martins
"""
import abc
class Battleship(object):
"""
classdocs
"""
__metaclass__ = abc.ABCMeta;
def fire(self):
raise NotImplementedError
def move(self):
raise NotImplementedError
class Captain(Battleship):
"""
classdocs
"""
def __init__(self, battleship=None):
'''
Constructor
'''
self.battleship = battleship
def fire(self):
self.battleship.fire()
def move(self):
self.battleship.move()
class BattleFishingBoat(Battleship):
"""
classdocs
"""
def __init__(self):
self.boat = FishihingBoat()
def fire(self):
print('Fire!')
def move(self):
self.boat.sail()
class BattleWarBoat(Battleship):
"""
classdocs
"""
def fire(self):
print('Fire the cannon!')
def move(self):
print('Move forward to death')
class FishihingBoat(object):
"""
classdocs
"""
def sail(self):
print('The Boat is moving to that place')
def fish(self):
print('Fishing...')