Question: Step 5 : Implement the SwapCommand class and GroceryList's swap _ with _ undo ( ) method Implement the SwapCommand class in SwapCommand.py . The

Step 5: Implement the SwapCommand class and GroceryList's swap_with_undo() method
Implement the SwapCommand class in SwapCommand.py. The class itself is declared, but no attributes yet exist. Add necessary attributes and methods so that the command can undo swapping two items in the grocery list.
Implement GroceryList's swap_with_undo() method. The method swaps list items at the specified indices, then pushes a SwapCommand, to undo that swap, onto the undo stack.
Step 6: Implement the InsertAtCommand class and GroceryList's remove_at_with_undo() method
Implement the InsertAtCommand class in InsertAtCommand.py. Add necessary fields and methods so that the command can undo removing a grocery list item at an arbitrary index.
Implement GroceryList's remove_at_with_undo() method. The method removes the list item at the specified index, then pushes an InsertAtCommand, to undo that removal, onto the undo stack.
596280.2369954.qx3zqy7

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 Programming Questions!