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

Assignment 4: A Freer FreeCell

Due: Tue 02/18 at 9:00pm; self-evaluation due Wed 02/19 at 10:00pm

Starter files: code

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.freecell.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 common 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 the cards 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.

Note that the ability to move multiple cards 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 legal even though it obeys the above two conditions, if there aren’t enough of these intermediate slots available. 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 enforce all three of these 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 called FreecellModelCreator. 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.

5 Deliverables

All new classes and interfaces for this homework should be in the cs3500.freecell.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://handins.ccs.neu.edu/ by the above deadline. Then be sure to complete your self evaluation by its deadline.