aggregation 3

This commit is contained in:
Mert Gör 🇹🇷 2023-06-27 18:25:57 +03:00
parent 0bef4ab495
commit fd8dfc3691
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
2 changed files with 49 additions and 0 deletions

View 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)

View 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()