Tally Counter Application Finish coding the Tally Counter Application which is s
ID: 3714622 • Letter: T
Question
Tally Counter Application
Finish coding the Tally Counter Application which is stored in the counter.py and counterdemo.py files located in Project 10 folder on Blackboard. We want to add a button to the tally counter that allows an operator to undo an accidental button click. Provide the undo(self) method that simulates such a button. The tally counter should also be used to admit a limited number of people. The limit is set with a call to the setLimit(self, maximum) method which you will need to code. If the count button is clicked more often than the limit, simulate an alarm by printing out a message “Limit exceeded”.
Note: To complete this assignment, you will need to use the counter.py and counterdemo.py files located in Project 10 folder on Blackboard. You will not be allowed to make any changes to counterdemo.py.
______________________________________________________________________
SAMPLE RUN
Value: 2
Limit Exceeded
Value: 3
Value: 2
Explanation / Answer
Solution:
code:
Note:
class Counter:
def getValue(self):
return self._value
def undo(self):
if self._value > 0:
self._value = self._value - 1;
def click(self):
self._value= self._value + 1
def reset(self):
self._value= 0
tally= Counter()
tally.reset()
tally.click()
tally.click()
result = tally.getValue()
print("Value:", result)
tally.click()
result = tally.getValue()
print("Value:", result)
tally.undo()
tally.undo()
result = tally.getValue()
print("Value:", result)
tally.undo()
tally.undo()
result = tally.getValue()
print("Value:", result)
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.