You are given a class PiggyBankthat represents an old-school moneybox in the shape of a pig. The class has two attributes: dollars and cents, their initial values are passed to the constructor.
Your goal is to implement an .add_money() method that:
Accepts two parameters:
deposit_dollarsanddeposit_centsIncreases the money in the piggy bank by the deposited amount (increases the values of
dollarsandcentsbydeposit_dollarsanddeposit_cents, respectively)Ensures that the
centsattribute never exceeds 99 (parametersdeposit_dollarsanddeposit_centsof theadd_moneymethod can have any value)
Some considerations:
The
PiggyBankconstructor initializesdollarsandcentswith given valuesThe
.add_money()method should handle any positive deposit amountIf adding cents results in 100 or more cents, convert the excess to dollars
For example, starting with PiggyBank(0, 50) (50 cents): adding 50 cents should result in 1 dollar and 0 cents (we will have to update the values of both dollars and cents because the attribute cents cannot be equal to 100).
Note:
Do not implement input processing
The class should work with any valid initial values and deposit amounts