import random
class Dice:
def __init__(self):
self.face=None
def roll(self):
self.face = (random.randint(1, 6), random.randint(1, 6))
def total(self):
return sum(self.face)
d1=Dice()
d1.roll()
print(d1.face)
print(d1.total())
python 初识类
最新推荐文章于 2024-08-14 12:00:04 发布