aggregation 3
This commit is contained in:
parent
0bef4ab495
commit
fd8dfc3691
25
python-temel/aggregation.3.py
Normal file
25
python-temel/aggregation.3.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
class Figure:
|
||||
def __init__(self, ftype, color):
|
||||
self.ftype = ftype
|
||||
self.color = color
|
||||
|
||||
class Square:
|
||||
def __init__(self, color):
|
||||
self.color = color
|
||||
self.figure = None
|
||||
|
||||
def set_figure(self, figure):
|
||||
self.figure = figure
|
||||
|
||||
def get_figure(self):
|
||||
return self.figure
|
||||
|
||||
class Board:
|
||||
def __init__(self):
|
||||
self.squares = [[Square('Beyaz' if (i + k) % 2 == 0 else 'Siyah' ) for i in range(8)] for k in range(8)]
|
||||
self.squares[0][0].figure = Figure('Kale', 'Siyah')
|
||||
self.squares[0][1].figure = Figure('At', 'Siyah')
|
||||
# ....
|
||||
|
||||
board = Board()
|
||||
#print(board)
|
24
python-temel/aggregation.3.py~
Normal file
24
python-temel/aggregation.3.py~
Normal file
|
@ -0,0 +1,24 @@
|
|||
class Figure:
|
||||
def __init__(self, ftype, color):
|
||||
self.ftype = ftype
|
||||
self.color = color
|
||||
|
||||
class Square:
|
||||
def __init__(self, color):
|
||||
self.color = color
|
||||
self.figure = None
|
||||
|
||||
def set_figure(self, figure):
|
||||
self.figure = figure
|
||||
|
||||
def get_figure(self):
|
||||
return self.figure
|
||||
|
||||
class Board:
|
||||
def __init__(self):
|
||||
self.squares = [[Square('Beyaz' if (i + k) % 2 == 0 else 'Siyah' ) for i in range(8)] for k in range(8)]
|
||||
self.squares[0][0].figure = Figure('Kale', 'Siyah')
|
||||
self.squares[0][1].figure = Figure('At', 'Siyah')
|
||||
# ....
|
||||
|
||||
board = Board()
|
Loading…
Reference in New Issue
Block a user