Import Randomclass coin:def __init__ (self, rare=false, Clean=true, **kwargs): For Key,value in Kwargs.items (): SetAttr (self,key,value) self.is_rare = Rare Self.is_clean = Clean Self.heads = Heads If Self.is_rare:self.value = self.original_value * 1.25 Else:self.value = Self.original_v Alue * 1.0 If Self.is_clean:self.color = Self.original_color Else:self.color = self. Rusted_color def Rust (self): Self.color = Self.rusted_color def clean (self): Self.color = Self.origina L_color def Flip (self): heads_options = [True, False] choice = Random.choice (heads_options) self.h EADS = Choice def __del__ (self): print (' Coin spent! ') Class Pound (Coin): def __init__ (self): data = {' Original_value ': 1.00, ' original_color ': ' Gold ', ' rusted_color ': ' Greenish ', ' Num_edge ': 1, ' Diameter ': 22.5, ' thickness ': 3.15, ' Mass ': 9.5} super (). __init__ (**data) # def __init__ (self, Rare=false): # self.rare = rare # if self.rare: # self.value = 1.25 # Else: # self.value = 1.00 # self.value = 1.00 # self.color = ' Gold ' # Self.num_edge = 1 # Self.diameter = 22.5 # self.thickness = 3.15 # self.heads = True # # def rust (self): # SELF.C Olor = ' greenish ' # def clean: # self.color = ' Gold ' # def flip (self): # heads_options = [True, False] # choice = Random.choice (heads_options) # self.heads = Choice # # def __del__ (self): # print (' Coin spent! ')
Learn Python 016:coin-a project of MSC, unfinished.