Skip to content
Snippets Groups Projects
Commit c6b93084 authored by Angy Wallot's avatar Angy Wallot
Browse files

tp.5

parent 1a2e2fd9
No related branches found
No related tags found
Loading
tp.5/cell.py 100644 → 100755
......@@ -30,7 +30,9 @@ class Cell:
$$$ cel.nbombs_in_neighborhood
0
"""
...
self.is_bomb = False
self.is_revealed = False
self.nbombs_in_neighborhood = 0
def incr_number_of_bombs_in_neighborhood(self):
"""
......@@ -46,7 +48,7 @@ class Cell:
$$$ cel.nbombs_in_neighborhood
1
"""
...
self.nbombs_in_neighborhood += 1
def reveal(self):
"""
......@@ -61,7 +63,8 @@ class Cell:
$$$ cel.is_revealed
True
"""
...
self.is_revealed = True
return self.is_revealed
def set_bomb(self):
"""
......@@ -77,7 +80,8 @@ class Cell:
$$$ cel.is_bomb
True
"""
...
self.is_bomb = True
return self.is_bomb
def __str__(self):
"""
......@@ -99,8 +103,14 @@ class Cell:
$$$ str(cel) == 'B'
True
"""
...
if not self.is_revealed:
return ' '
else:
if self.is_bomb == True:
return 'B'
else:
return f"{self.nbombs_in_neighborhood}"
if (__name__ == '__main__'):
import apl1test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment