Assignment 4: A Freer Free  Cell
1 Purpose
2 Multi-move Freecell
3 Design Constraints
4 The FreeCellModelCreator class
5 Deliverables
6 Grading standards
6.7

Assignment 4: A Freer FreeCell

Due: Fri 10/14 at 8:59pm; self-evaluation due Sat 10/15 at 8:59pm

Starter files: code.zip

1 Purpose

In this assignment we will reap the fruits of our design, by introducing a new variant in the game of Freecell: the ability to move several cards at once. You will see how your earlier design of this program will facilitate adding this feature with (hopefully) minimal change in code.

All new classes and interfaces for this homework should be in the cs3500.hw04 package. All classes written in previous assignments, even if improved upon, should remain in their respective packages.

We are giving you a starter file whose sole purpose is to ensure your code is in the correct packages with the correct visibility.

2 Multi-move Freecell

A more realistic version of Freecell is one where the player can move several cards at once from one cascade pile to another (while it is also possible to move several cards from a cascade pile to a foundation pile, we will ignore this feature in this variation).

Moving multiple cards must obey two conditions. The first condition is that they should form a valid build, i.e. they should be arranged in alternating colors and consecutive, descending values in the cascade pile that they are moving from. The second condition is the same for any move to a cascade pile: these cards should form a build with the last card in the destination cascade pile.

It may be noted that the ability of moving cards (besides the two conditions above) is not a special feature, but a convenience to the player. A multi-card move is basically several single-card moves, using free open piles and empty cascade piles as “intermediate slots”. Thus a multi-card move may not be feasible even though it obeys the above two conditions, if there aren’t enough of these intermediate slots. More specifically, it can be proved that the maximum number of cards that can be moved when there are N free open piles and K empty cascade piles is (N+1)*2K. Your implementation of this variation should work within all these three conditions.

In order to use an empty cascade pile as an intermediary for multi-card moves, we will allow any card to move to an empty cascade pile (not just a king, as some Freecell versions mandate).

3 Design Constraints

In this assignment, you must introduce this new feature in your game while respecting the following constraints:

You may have to refactor your earlier design to do this. This is OK, but should be properly documented and justified. Again, you are not allowed to change existing interfaces or add new public methods.

4 The FreeCellModelCreator class

Write a class with the above name. The class should define a public enum GameType with two possible values SINGLEMOVE and MULTIMOVE. It should offer a static factory method create(GameType type) that returns either a FreeCellModel or an object of your multi-card-move model, depending on the value of the parameter. HINT: Think carefully about the return type of this factory method.

5 Deliverables

All new classes and interfaces for this homework should be in the cs3500.hw04 package. All classes written in previous assignments, even if improved upon, should be in their own packages.

6 Grading standards

For this assignment, you will be graded on

Please submit your homework to https://cs3500.ccs.neu.edu/ by the above deadline. Then be sure to complete your self evaluation by its deadline.