Skip to content

Commit c87f6d4

Browse files
authored
First Commit
Design: 3:32
1 parent 1e0befd commit c87f6d4

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

queen_attack.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Queen(object):
2+
def __init__(self, row, column):
3+
4+
if -1<row<8 and -1<column<8:
5+
self.row = row
6+
self.column = column
7+
else:
8+
raise ValueError('ValueError')
9+
10+
def can_attack(self, another_queen):
11+
12+
if self.row==another_queen.row and self.column==another_queen.column:
13+
raise ValueError('ValueError')
14+
15+
if self.row==another_queen.row or self.column==another_queen.column:
16+
return True
17+
elif (abs(self.row-another_queen.row))==(abs(self.column-another_queen.column)):
18+
return True
19+
else:
20+
return False

0 commit comments

Comments
 (0)