Question
Using Python define class MoneyType, withits properties and methods described belowmake sure you use theexact same names as indicated in the description. Test allmethods below
Using Python define class MoneyType, withits properties and methods described below–make sure you use theexact same names as indicated in the description. Test allmethods below your class definition(i.e. in the same file–wewilluse your code toverify you tested thoroughly and then run it toverify correctness). No credit for un-testedfunctionality, as in Python the code is not verified untilrun-time
1. constructor that takes two parameters that are to be used fordollars and cents, and assigns their values to privatefields; the constructor should provide default values of0for these parameters(do NOT worry about normalizing thevalues)
2. A class level field that counts the number of MoneyTypeobjects (needs to be updated inside the constructor; make sure youtest it as well)
3 .getters and setters foreach of the properties
4. __str__method that returns a money object as astring–format the string in some fashion, e.g. $1.12
5. __add__method that takes another MoneyType object andreturns a new MoneyType object that is the result of adding selfand param(if you name this method correctly, then it means that inPython you overloaded the addition operator and in your test code,you can use something like object3 = object1 +object2); doNOT worry about normalizing the values
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