-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vaisseaux.py
118 lines (86 loc) · 3.11 KB
/
Vaisseaux.py
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from Armes import Lance_missiles_anti_air, Lance_missiles_antisurface, Lance_torpilles
class Vessel():
def _init_(self, coordinates, max_hits, weapon):
self.coordinates= coordinates
self.max_hits= max_hits
self.weapon =weapon
def go_to(self,x:int,y:int,z:int):
self.coordinates=(x,y,z)
def get_coordinates(self):
return self.coordinates
def fire_at(self,x:int,y:int,z:int):
if self.ammo > 0:
print(f"Firing at coordinates ({x}, {y}, {z})")
self.ammo -= 1
else:
print("NoAmmunitionError")
class Cruiser(Vessel):
def _init_(self, coordinates, max_hits, weapon):
self.coordinates=coordinates
self.max_hits=6
self.weapon= Lance_missiles_anti_air
def go_to(self,x:int,y:int,z:int):
if z==0:
self.coordinates=(x,y,z)
else:
return 'deplacement impossible'
def get_coordinates(self):
return super().get_coordinates()
def fire_at(self, x: int, y: int, z: int):
return self.weapon.fire_at(x, y, z)
class Submarine(Vessel):
def _init_(self, coordinates, max_hits, weapon):
self.coordinates=coordinates
self.max_hits=2
self.weapon= Lance_torpilles
def go_to(self,x:int,y:int,z:int):
if z==0 or z==-1:
self.coordinates=(x,y,z)
else:
return 'deplacement impossible'
def get_coordinates(self):
return super().get_coordinates()
def fire_at(self, x: int, y: int, z: int):
return self.weapon.fire_at(x, y, z)
class Frigate(Vessel):
def _init_(self, coordinates, max_hits, weapon):
self.coordinates=coordinates
self.max_hits=5
self.weapon= Lance_missiles_antisurface
def go_to(self,x:int,y:int,z:int):
if z==0:
self.coordinates=(x,y,z)
else:
return 'deplacement impossible'
def get_coordinates(self):
return super().get_coordinates()
def fire_at(self, x: int, y: int, z: int):
return self.weapon.fire_at(x, y, z)
class Destroyer(Vessel):
def _init_(self, coordinates, max_hits, weapon):
self.coordinates=coordinates
self.max_hits=4
self.weapon= Lance_torpilles
def go_to(self,x:int,y:int,z:int):
if z==0:
self.coordinates=(x,y,z)
else:
return 'deplacement impossible'
def get_coordinates(self):
return super().get_coordinates()
def fire_at(self, x: int, y: int, z: int):
return self.weapon.fire_at(x, y, z)
class Aircraft(Vessel):
def _init_(self, coordinates, max_hits, weapon):
self.coordinates=coordinates
self.max_hits=1
self.weapon= Lance_missiles_antisurface
def go_to(self,x:int,y:int,z:int):
if z==1:
self.coordinates=(x,y,z)
else:
return 'deplacement impossible'
def get_coordinates(self):
return super().get_coordinates()
def fire_at(self, x: int, y: int, z: int):
return self.weapon.fire_at(x, y, z)