-


> > > > Programming Assignments > Assignment 5 - Polymorphic Game
DRAFT

Objectives

Assignment

Refactor your Conway and SpinOut classes so they work with the provided main. Provide a makefile that produces an executable called Game.

The behavior of the Game program should be the same as the SpinOut and Conway programs, accounting for the additional command-line argument to determine which game to play and for the repositioned -i argument, and except as noted below.

Your solution should follow good object-oriented design. (So use inheritance and declare members in the base class where it makes sense to do so. Don't create one class that implements both games.)

The constructors for Conway should still work, as should the assignment operators when the object assigned to is of static type Conway.

(CS527) Make sure your makefile compiles main with the -DCS527 option to select the code that creates the Game objects using a factory. The factory may throw exceptions when used to create a game initialized from a source the game does not support (from a file for SpinOut and from a string for Conway's Soldiers).

(CS527) The version of Game compiled without the -DCS527 option should work as well.

We also reserve the right to deduct points from submissions for violations of the following guidelines.

File and Submissions

Submit everything you need in order to build Game, including the unchanged game_main.cpp.

Example

The following is a transcript of running the Game program in various ways.
[jrg94@tick Game]$ ./Game spinout -i
///////
6
//////-
5
illegal move
4
////-/-
[jrg94@tick Game]$ ./Game spinout -s ------/ -i
------/
6
-------
1 moves
[jrg94@tick Game]$ ./Game spinout -s ------/ 6
SOLVED
[jrg94@tick Game]$ ./Game spinout 6 4 5
illegal move 5 in position 3 for
////-/-
[jrg94@tick Game]$ ./Game spinout 6 4 6 5 6
////---
[jrg94@tick Game]$ ./Game conway -i
......
......
.XXX..
...X..
......

3 3 1 3
......
...X..
.XX...
......
......

1 3 0 3
illegal move
2 1 2 3
......
...X..
...X..
......
......

[jrg94@tick Game]$ ./Game conway -f conway_2.in -i
...
.X.
.X.

2 1 0 1
.X.
...
...

1 moves
[jrg94@tick Game]$ ./Game conway 3 3 1 3  2 1 2 3  2 3 0 3
SOLVED
[jrg94@tick Game]$ ./Game conway 3 3 1 3  1 3 0 3  2 1 2 3  2 3 2 1
illegal move 1 3 0 3 in position 2 for
......
...X..
.XX...
......
......

[jrg94@tick Game]$ ./Game conway -f conway_21.in 5 4 3 4  5 2 5 4
.........
.........
.........
....X....
..XX.XX..
....XXX..
..XXXXX..
..XXXXX..
....X....

Where conway_2.in contains

3 3
...
.X.
.X.
and conway_21.in contains
9 9
.........
.........
.........
.........
..XXXXX..
..XXXXX..
..XXXXX..
..XXXXX..
....X....

Valid HTML 4.01 Transitional