Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python. Answer the questions with Your Code Here : Please check your answer before submitting... Complete the Mint and Coin classes so that the coins
Python. Answer the questions with "Your Code Here" :
Please check your answer before submitting...
Complete the Mint and Coin classes so that the coins created by a mint have the correct year and worth Each Mint instance has a year stamp. The update method sets the year stamp to the current_year class attribute of the Mint class The create method takes a subclass of Coin and returns an instance of that class stamped with the mint 's year (which may be different from Mint.current_year if it has not been updated.) A Coin 's worth method returns the cents value of the coin plus one extra cent for each year of age beyond 50. A coin's age can be determined by subtracting the coin's year from the current_year class attribute of the Mint class. class Mint: ""A mint creates coins by stamping on years. The update method sets the mint's stamp to Mint.current_year. >>>mint - Mint >>> mint.year 2017 >>dime -mint.create(Dime) >> dime.year 2017 >>> Mint.current-year 2100 # Time passes >>> nickel - mint.create(Nickel) >> nickel.year 2017 >>> nickel.worth() # 5 cents + (83-50 years) # The mint has not updated its stamp yet >>> mint.update() # The mint's year is updated to 2100 >>> Mint.current year2175 >>> mint.create (Dime).worth() # 10 cents + (75-50 years) 35 >>> Mint().create(Dime).worth() # A new mint has the current year 10 > dime.worth() 118 >>> Dime . cents 20 # Upgrade all dimes! >> dime.worth 128 # More time passes # 10 cents + (160-50 years) # 20 cents + (160-50 years) current_year 2017 current_year 2017 def init_ (self): self.update() def create(self, kind): YOUR CODE HERE def update(self): YOUR CODE HERE class Coin: def init_(self, year): self.year-year def worth(self): YOUR CODE HERE class Nickel(Coin): cents-5 class Dime (Coin): cents 10
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started