<p>我有一门描述棋子的课。我为棋盘上所有类型的棋子制作一个类,例如棋子、皇后、基恩等。。。
我在典当类有问题我想转换为皇后或其他有类的对象(当典当转到第8行然后转换为其他对象)我该怎么做?</p>
<pre><code>class Pawn:
def __init__(self ,x ,y):
self.x = x
self.y = y
def move(self ,unit=1):
if self.y ==7 :
self.y += 1
what = raw_input("queen/rook/knight/bishop/(Q,R,K,B)?")
# There is most be changed that may be convert to:
# Queen ,knight ,bishop ,rook
if self.y != 2 and unit == 2:
print ("not accesible!!")
elif self.y ==2 and unit == 2:
self.y += 2
elif unit == 1:
self.y += 1
else:
print("can`t move over there")
</code></pre>