2. Write a standalone function partyVolume() that takes accepts one argument, a string containing the name of a file. The objective of the function is to determine the a Volume object that is the result of many people at a party turning the Volume up and down. More specifically: the first line of the file is a number that indicates the initial value of a Volume object. The remaining lines consist of a single character followed by a space followed by a number. The character will be one of 'U" or 'D' which stand for "up" and "down" respectively. The function will create a new Volume object and then process each line of the file by calling the appropriate method of the Volume object which changes the value of the Volume. The function then returns the final Volume object. Guidelines/hints: E This is a standalone function, it should NOT be inside (indented within) the class. It should be listed in the module after the Volume class and without indentation. O Note that the first line of the file will be treated differently than all the other lines. Probably the easiest way to do this is to 1) open the file, 2) call the .readline() method (no s!) which reads a single line, the initial value of the Volume, then 3) call the .readlines () method which reads the rest of the lines. Item 2) will be used to set the initial Volume and 3) will be iterated over to represent turning the volume up and down some number of time. O Make sure you return the final Volume object.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
In Python IDLE: How would I write code for the two problems in the attached image?
1. Develop a class Volume that stores the volume for a stereo that has a value between 0 and11. Usage of the
class is listed below the problem descriptions. Throughout the class you must guarantee that:
E 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.
O 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 <= vol <=11 constraint above.)
repr_- converts Volume to a str for display, see runs below.
2 set - sets the volume to the specified argument (Subject to 0 <= vol <=11 constraint above.)
2 get - returns the numeric value of the Volume
2 up – given a numeric amount, increases the Volume by that amount. (Subject to 0 <= vol <=11
constraint above.)
2 down – given a numeric amount, decreases the Volume by that amount. (Subject to 0 <= vol <=11
constraint above.)
eq_ - implements the operator ==.
False otherwise.
Returns True if the two Volumes have the same value and
2. Write a standalone function partyVolume() that takes accepts one argument, a string containing the name
of a file. The objective of the function is to determine the a Volume object that is the result of many people
at a party turning the Volume up and down. More specifically: the first line of the file is a number that
indicates the initial value of a Volume object. The remaining lines consist of a single character followed by
a space followed by a number. The character will be one of 'U" or 'D' which stand for "up" and "down"
respectively. The function will create a new Volume object and then process each line of the file by calling
the appropriate method of the Volume object which changes the value of the Volume. The function then
returns the final Volume object. Guidelines/hints:
2 This is a standalone function, it should NOT be inside (indented within) the class. It should be listed
in the module after the Volume class and without indentation.
E Note that the first line of the file will be treated differently than all the other lines. Probably the
easiest way to do this is to 1) open the file, 2) call the .readline() method (no s!) which reads a
single line, the initial value of the Volume, then 3) call the .readlines() method which reads
the rest of the lines. Item 2) will be used to set the initial Volume and 3) will be iterated over to
represent turning the volume up and down some number of time.
2 Make sure you return the final Volume object.
Transcribed Image Text:1. Develop a class Volume that stores the volume for a stereo that has a value between 0 and11. Usage of the class is listed below the problem descriptions. Throughout the class you must guarantee that: E 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. O 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 <= vol <=11 constraint above.) repr_- converts Volume to a str for display, see runs below. 2 set - sets the volume to the specified argument (Subject to 0 <= vol <=11 constraint above.) 2 get - returns the numeric value of the Volume 2 up – given a numeric amount, increases the Volume by that amount. (Subject to 0 <= vol <=11 constraint above.) 2 down – given a numeric amount, decreases the Volume by that amount. (Subject to 0 <= vol <=11 constraint above.) eq_ - implements the operator ==. False otherwise. Returns True if the two Volumes have the same value and 2. Write a standalone function partyVolume() that takes accepts one argument, a string containing the name of a file. The objective of the function is to determine the a Volume object that is the result of many people at a party turning the Volume up and down. More specifically: the first line of the file is a number that indicates the initial value of a Volume object. The remaining lines consist of a single character followed by a space followed by a number. The character will be one of 'U" or 'D' which stand for "up" and "down" respectively. The function will create a new Volume object and then process each line of the file by calling the appropriate method of the Volume object which changes the value of the Volume. The function then returns the final Volume object. Guidelines/hints: 2 This is a standalone function, it should NOT be inside (indented within) the class. It should be listed in the module after the Volume class and without indentation. E Note that the first line of the file will be treated differently than all the other lines. Probably the easiest way to do this is to 1) open the file, 2) call the .readline() method (no s!) which reads a single line, the initial value of the Volume, then 3) call the .readlines() method which reads the rest of the lines. Item 2) will be used to set the initial Volume and 3) will be iterated over to represent turning the volume up and down some number of time. 2 Make sure you return the final Volume object.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY