Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

Students also viewed these Programming questions

Question

What is the adjusted present value of this project? LO.1

Answered: 1 week ago