CS120
Programming Assignment #8
Due Monday, Oct. 27 at midnight.
Begin by entering the Generic Board Game from Chapter 6
and
creating the file "game.txt" (Listing 6.4 from the text).
Make sure that the
program compiles and runs. Make sure you understand how the program works.
Pay particular attention to how data is loaded from a file into the
array of objects and how objects in the array are accessed.
After you are comfortable with the program make the following changes:
- Chapter 6, Exercise 1 (pg. 85) - Rewrtie the "game.txt" file to
customize the game. Make sure to pick a theme (sailing, racing, zombie killing,
candyland, etc.) and make the messages fit the theme.
- Chapter 6, Exercise 2 (pg. 86) - Add an introduction to the game that
"sets the stage" and explains the rules.
Extra Credit: Make the introductory text
part of the "game.txt" file so it gets read in from the file, rather than
printed directly from the program.
- Chapter 6, Exercise 4 (pg. 86) - Allow each player to choose the character
that they want to use as their "piece". For example one player could chose
the character 'T' and another player could choose '8'. This change will require new (char) variables to
store the players' "pieces" and code at the beginning of the program to
ask the user what character they want to use.
- Chapter 6, Problem 2 (pg. 87) - Create special square that move the player
a random distance. The action() function will need to be modified to generate
a random value instead of a single value. In addition, the "game.txt" file,
the read_board()
function, and the square class will all need to be rewritten so that
there is a way to indicate and
remember whether a special square should be a random square
or a deterministic square. For example, one
approach is to use two integers in the "game.txt" file to set the
upper and lower limits of a
random move.
If the two bounds are the same (e.g., -3 and -3),
then the move is deterministic instead of random.
- Chapter 6, Problem 4 (pg. 87) - Add an additional game variable for each
player, for example, gold or health or fame. Change the program so that
special squares also effect these variables. As with the previous problem
this will require changing the "game.txt" file to record the effect of a
square, and changing the read_board() and action() functions to correctly implement
the new effect.
Turn in: To turn the program you will need to combine both your main
program and your game file into one file that you can use cscheckin to submit.
On a Unix computer you do this be taring the files together.
Use the command:
tar -cvf assignment8.tar assignment8.cpp game.txt
This will combine the files assignment8.cpp and
game.txt into one file called
assignment8.tar.
Submit assignment8.tar using cscheckin.
(tar is short for Tape ARchive. The command was originally used for storing
file systems onto magnetic tape (yes, Unix is that old), but now it is also
commonly used just for "bundling" files.)