Question: In Python: We want to add a button to the tally counter in Section 9.2 that allows an operator to undo an accidental button click.

In Python:

We want to add a button to the tally counter in Section 9.2 that allows an operator to undo an accidental button click. Provide a method

def undo(self)

that simulates such a button. As an added precaution, make sure that the operator cannot click the undo button more often than the click button.

Here are the 9.2 tally counter codes:

Part 1

class Counter: def getValue(self): return self._value

def click(self): self._value= self._value + 1 def reset(self): self._value= 0

Part 2:

tally= Counter() tally.reset() tally.click() tally.click() result = tally.getValue() print("Value:", result) tally.click() result = tally.getValue() print("Value:", result)

Thanks for the input!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!