Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please perform on Python and keep it basic so it is easy to follow. Please break down parts and with brief explanations. Lastly, but most

image text in transcribed

Please perform on Python and keep it basic so it is easy to follow. Please break down parts and with brief explanations. Lastly, but most important!! - Please make sure ALL of the sample output has been tested and the answers match accordingly. It is a lot but, it does not help if any part is incorrect so please make sure ALL answers match the sample outputs EXACTLY!

Thank you!

Sample Output:

##### Volume #####

# set and get

>>> v = Volume()

>>> v.set(5.3)

>>> v

Volume(5.3)

>>> v.get()

5.3

>>> v.get()==5.3 # return not print

True

v.set(13.2)

>>> v Volume(11)

>>> v.set(-1.2)

>>> v Volume(0)

>>>

# __init__, __repr__, up, down

>>> v = Volume(4.5) # set Volume with value

>>> v

Volume(4.5)

>>> v.up(1.4)

>>> v

Volume(5.9)

>>> v.up(6) # should max out at 11

>>> v

Volume(11)

>>> v.down(3.5)

>>> v

Volume(7.5)

>>> v.down(10) # minimum must be 0

>>> v

Volume(0)

# default arguments for __init__

>>> v = Volume() # Volume defaults to 0

>>> v

Volume(0)

# can compare Volumes using ==

>>> # comparisons

>>> v = Volume(5)

>>> v.up(1.1)

>>> v == Volume(6.1)

True

>>> Volume(3.1) == Volume(3.2)

False

# constructor cannot set the Volume greater

# than 11 or less than 0

>>> v = Volume(20)

>>> v

Volume(11)

>>> v = Volume(-1)

>>> v

Volume(0)

>>>

##### partyVolume #####

>>> partyVolume('party1.txt')

Volume(4)

>>> partyVolume('party2.txt')

Volume(3.75)

>>> partyVolume('party3.txt')

Volume(0.75)

# make sure return not print

>>> partyVolume('party1.txt')==Volume(4) # return not print

True

>>> partyVolume('party2.txt')==Volume(3.75)

True

>>> partyVolume('party3.txt')==Volume(0.75)

True

Develop a class Vol ume that stores the volume for a stereo that has a value between 0 and 11 . Usage of the class is listed below the problem descriptions. Throughout the class you must guarantee that: - The numeric value of the Volume is set to a number between 0 and 11. Any attempt to set the value to greater than 11 will set it to 11 instead, any attempt to set a negative value will instead set it to 0 . - This applies to the following methods below: init, set, up, down You must write the following methods: - init - constructor. Construct a Volume that is set to a given numeric value, or, if no number given, defaults the value to 0 . (Subject to 0

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

More Books

Students also viewed these Databases questions

Question

Which team solution is more likely to be pursued and why?

Answered: 1 week ago

Question

4. I can tell when team members dont mean what they say.

Answered: 1 week ago