Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import annotations
- class Command:
- def __init__(self, arr, value):
- self.arr = arr
- self.multiplier = value
- commands = []
- def PushIn(self, command):
- self.commands.append(command)
- def pop(self):
- self.commands.pop()
- def execute(self):
- for i in range(len(self.arr)):
- for j in range(len(self.arr[i])):
- self.arr[i][j] += self.multiplier
- return self.arr
- def redo(self):
- for i in range(len(self.arr)):
- for j in range(len(self.arr[i])):
- self.arr[i][j] += self.multiplier
- self.PushIn(self.execute())
- def undo(self):
- for i in range(len(self.arr)):
- for j in range(len(self.arr[i])):
- self.arr[i][j] -= self.multiplier
- self.commands.pop()
- class CommandExecutor:
- class App:
- def PrintArray(arr):
- for i in range(len(arr)):
- print(*arr[i])
- def main(self):
- print('starting')
- arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
- plus = Command(arr, 5)
- plus.execute()
- self.PrintArray(arr)
- App.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement