Multi-Level Undo Redo

Learning Objectives

The purpose of this lab is to give you an opportunity to learn the following skills:

  • Refactoring existing code if necessary.
  • Learning how to implement multi-level undo redo.
  • Applying object-oriented design principles to develop an elegant solution.

Implementing Multi-Level Undo and Redo in the FreeCell Game

For this lab, please do the following activities:

1. If necessary, refactor/redesign your initial solution based on the design principles youve seen in the lectures and labs.

2. Make a plan how you are going to implement undo and redo. Discuss your plan with the lab instructor and make sure that you understand the requirements of the multi-level undo redo features. Being able to design an elegant solution is one of this labs main objectives, so please put significant effort to come up with a good design.

3. Add the multi-level undo and redo features to your FreeCell implementation. Please ask questions if you need clarification.

Example (user input is underlined):

F0: []
F1: []
F2: []
F3: []
H0: []
H1: []
H2: []
H3: []
T0: [6♦, Q♠, 8♥, 3♠, A♠, 8♠, A♣]
T1: [10♦, J♥, 9♣, 4♣, 8♦, Q♦, J♣]
T2: [4♦, J♠, 5♦, 5♠, 2♠, 9♥, 6♣]
T3: [K♣, 8♣, 4♠, 7♣, K♦, 10♠, A♥]
T4: [Q♣, 6♥, 4♥, 10♥, 7♥, 7♠]
T5: [3♣, K♥, 3♦, 2♥, 10♣, Q♥]
T6: [A♦, 9♦, 5♥, K♠, 7♦, J♦]
T7: [6♠, 2♦, 9♠, 3♥, 2♣, 5♣]
Your move < from to> (0 to exit, U to undo, R to redo): T0 H0
F0: []
F1: []
F2: []
F3: []
H0: [A♣]
H1: []
H2: []
H3: []
T0: [6♦, Q♠, 8♥, 3♠, A♠, 8♠]
T1: [10♦, J♥, 9♣, 4♣, 8♦, Q♦, J♣]
T2: [4♦, J♠, 5♦, 5♠, 2♠, 9♥, 6♣]
T3: [K♣, 8♣, 4♠, 7♣, K♦, 10♠, A♥]
T4: [Q♣, 6♥, 4♥, 10♥, 7♥, 7♠]
T5: [3♣, K♥, 3♦, 2♥, 10♣, Q♥]
T6: [A♦, 9♦, 5♥, K♠, 7♦, J♦]
T7: [6♠, 2♦, 9♠, 3♥, 2♣, 5♣]
Your move < from to> (0 to exit, U to undo, R to redo): T3 H1
F0: []
F1: []
F2: []
F3: []
H0: [A♣]
H1: [A♥]
H2: []
H3: []
T0: [6♦, Q♠, 8♥, 3♠, A♠, 8♠]
T1: [10♦, J♥, 9♣, 4♣, 8♦, Q♦, J♣]
T2: [4♦, J♠, 5♦, 5♠, 2♠, 9♥, 6♣]
T3: [K♣, 8♣, 4♠, 7♣, K♦, 10♠]
T4: [Q♣, 6♥, 4♥, 10♥, 7♥, 7♠]
T5: [3♣, K♥, 3♦, 2♥, 10♣, Q♥]
T6: [A♦, 9♦, 5♥, K♠, 7♦, J♦]
T7: [6♠, 2♦, 9♠, 3♥, 2♣, 5♣]
Your move < from to> (0 to exit, U to undo, R to redo): T0 F0
F0: [8♠]
F1: []
F2: []
F3: []
H0: [A♣]
H1: [A♥]
H2: []
H3: []
T0: [6♦, Q♠, 8♥, 3♠, A♠]
T1: [10♦, J♥, 9♣, 4♣, 8♦, Q♦, J♣]
T2: [4♦, J♠, 5♦, 5♠, 2♠, 9♥, 6♣]
T3: [K♣, 8♣, 4♠, 7♣, K♦, 10♠]
T4: [Q♣, 6♥, 4♥, 10♥, 7♥, 7♠]
T5: [3♣, K♥, 3♦, 2♥, 10♣, Q♥]
T6: [A♦, 9♦, 5♥, K♠, 7♦, J♦]
T7: [6♠, 2♦, 9♠, 3♥, 2♣, 5♣]
Your move < from to> (0 to exit, U to undo, R to redo): U
F0: []
F1: []
F2: []
F3: []
H0: [A♣]
H1: [A♥]
H2: []
H3: []
T0: [6♦, Q♠, 8♥, 3♠, A♠, 8♠]
T1: [10♦, J♥, 9♣, 4♣, 8♦, Q♦, J♣]
T2: [4♦, J♠, 5♦, 5♠, 2♠, 9♥, 6♣]
T3: [K♣, 8♣, 4♠, 7♣, K♦, 10♠]
T4: [Q♣, 6♥, 4♥, 10♥, 7♥, 7♠]
T5: [3♣, K♥, 3♦, 2♥, 10♣, Q♥]
T6: [A♦, 9♦, 5♥, K♠, 7♦, J♦]
T7: [6♠, 2♦, 9♠, 3♥, 2♣, 5♣]
Your move < from to> (0 to exit, U to undo, R to redo): U
F0: []
F1: []
F2: []
F3: []
H0: [A♣]
H1: []
H2: []
H3: []
T0: [6♦, Q♠, 8♥, 3♠, A♠, 8♠]
T1: [10♦, J♥, 9♣, 4♣, 8♦, Q♦, J♣]
T2: [4♦, J♠, 5♦, 5♠, 2♠, 9♥, 6♣]
T3: [K♣, 8♣, 4♠, 7♣, K♦, 10♠, A♥]
T4: [Q♣, 6♥, 4♥, 10♥, 7♥, 7♠]
T5: [3♣, K♥, 3♦, 2♥, 10♣, Q♥]
T6: [A♦, 9♦, 5♥, K♠, 7♦, J♦]
T7: [6♠, 2♦, 9♠, 3♥, 2♣, 5♣]
Your move < from to> (0 to exit, U to undo, R to redo): R
F0: []
F1: []
F2: []
F3: []
H0: [A♣]
H1: [A♥]
H2: []
H3: []
T0: [6♦, Q♠, 8♥, 3♠, A♠, 8♠]
T1: [10♦, J♥, 9♣, 4♣, 8♦, Q♦, J♣]
T2: [4♦, J♠, 5♦, 5♠, 2♠, 9♥, 6♣]
T3: [K♣, 8♣, 4♠, 7♣, K♦, 10♠]
T4: [Q♣, 6♥, 4♥, 10♥, 7♥, 7♠]
T5: [3♣, K♥, 3♦, 2♥, 10♣, Q♥]
T6: [A♦, 9♦, 5♥, K♠, 7♦, J♦]
T7: [6♠, 2♦, 9♠, 3♥, 2♣, 5♣]
Your move < from to> (0 to exit, U to undo, R to redo): R
F0: [8♠]
F1: []
F2: []
F3: []
H0: [A♣]
H1: [A♥]
H2: []
H3: []
T0: [6♦, Q♠, 8♥, 3♠, A♠]
T1: [10♦, J♥, 9♣, 4♣, 8♦, Q♦, J♣]
T2: [4♦, J♠, 5♦, 5♠, 2♠, 9♥, 6♣]
T3: [K♣, 8♣, 4♠, 7♣, K♦, 10♠]
T4: [Q♣, 6♥, 4♥, 10♥, 7♥, 7♠]
T5: [3♣, K♥, 3♦, 2♥, 10♣, Q♥]
T6: [A♦, 9♦, 5♥, K♠, 7♦, J♦]
T7: [6♠, 2♦, 9♠, 3♥, 2♣, 5♣]
Your move < from to> (0 to exit, U to undo, R to redo): R
Nothing to redo.
Your move < from to> (0 to exit, U to undo, R to redo):
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.