• 20181213作业


    
    
    '''
    扑克牌
    '''
    
    class Poker():
         def __init__(self,color,number):
              self.color = color
              self.number = number
    
    #实例化对象
    all_number = ['A','2','3','4','5','6','7','8','9','10','J','Q','K']
    all_color = ['黑桃','红桃','梅花','方片']
    
    all_poker = []
    
    for j in all_color :
         for i in all_number :
              k = j+i
              k = Poker(j,i)
              all_poker.append(k.color+k.number)
    
    #print(all_poker)
    
    class Person():
         def __init__(self,name):
              self.name = name
    
    
    a = Person('赵先生')
    b = Person('钱先生')
    c = Person('孙先生')
    d = Person('李先生')
    
    all_people = (a.name,b.name,c.name,d.name)
    
    #print(all_people)
    
    
    import random
    
    class Deal():
         '''洗牌与发牌'''
         def xipai(all_poker):
              '''洗牌'''
              random.shuffle(all_poker)
              return all_poker
    
         def fapai(all_people,all_poker):
              '''发牌'''
              for k in range(len(all_poker)) :
                   if k <= 12 :
                        print('{}--->{}'.format(all_poker[k],all_people[0]))
                   elif 13 <= k <= 25 :
                        print('{}--->{}'.format(all_poker[k],all_people[1]))
                   elif 26 <= k <= 38 :
                        print('{}--->{}'.format(all_poker[k],all_people[2]))
                   else :
                        print('{}--->{}'.format(all_poker[k],all_people[3]))
              
    
    Deal.xipai(all_poker)         #洗牌
    
    #print(all_poker)
    print('''
    
    
    ''')
    
    Deal.fapai(all_people,all_poker)             #发牌
    
    
    
    '''
    扑克牌
    '''
    
    class Poker():
         def __init__(self,color,number):
              self.color = color
              self.number = number
    
    #实例化对象
    all_number = ['A','2','3','4','5','6','7','8','9','10','J','Q','K']
    all_color = ['黑桃','红桃','梅花','方片']
    
    all_poker = []
    
    for j in all_color :
         for i in all_number :
              k = j+i
              k = Poker(j,i)
              all_poker.append(k.color+k.number)
    
    #print(all_poker)
    
    
    import random
    
    q = []
    w = []
    e = []
    r = []
    
    random.shuffle(all_poker)
    
    
    for i in range(len(all_poker)) :
         if i <= 12 :
              q.append(all_poker[i])
         elif 13 <= i <= 25 :
              w.append(all_poker[i])
         elif 26 <= i <= 38 :
              e.append(all_poker[i])
         else :
              r.append(all_poker[i])
    
    print()
    print('赵先生的手牌是  {}'.format(q))
    print()
    print('钱先生的手牌是  {}'.format(w))
    print()
    print('孙先生的手牌是  {}'.format(e))
    print()
    print('李先生的手牌是  {}'.format(r))
    print()
  • 相关阅读:
    c#项目架构搭建经验
    c++ template怎么使用及注意事项
    c++怎么将一个类,拆分出接口类,和实现类
    c++l类
    错过C++
    Fixed 鸟粪一样的TreeView下的NodeMouseDoubleClick Bug
    Oracle 12C 新特性之表分区带 异步全局索引异步维护(一次add、truncate、drop、spilt、merge多个分区)
    Oracle 12C 新特性之在线重命名、迁移活跃的数据文件
    Oracle 12C 新特性之级联truncate
    Oracle 12C 新特性之扩展数据类型(extended data type)
  • 原文地址:https://www.cnblogs.com/mabaohua/p/10116205.html
Copyright © 2020-2023  润新知