class Pai:
def __init__(self,pai):
self.pai = pai
def __str__(self):
return '{}'.format(self.pai)
p1 = Pai('♥A')
p2 = Pai('♠K')
class Hand:
def __init__(self,pai):
self.poker = pai
left_hand = Hand(p1)
right_hand = Hand(p2)
class Person:
def __init__(self,left_hand,right_hand):
self.left_hand = left_hand
self.right_hand = right_hand
def show(self):
print('左手:',left_hand.poker,'右手:',right_hand.poker)
print('******交换手牌******')
left_hand.poker,right_hand.poker = right_hand.poker,left_hand.poker
print('左手:',left_hand.poker,'右手:',right_hand.poker)
fdy = Person(left_hand,right_hand)
fdy.show()
Python学习:左右手交换手牌
最新推荐文章于 2022-03-16 10:12:58 发布