CAB201 Programming Principles Assignment: Major Project – Space Race

CAB201 Programming Principles
Assignment: Major Project – Space Race
Addendum: Test data
Semester 2, 2018
INTRODUCTION
You are required to include a small amount of code and a data file in two directories which will assist
in the marking of your assignment and indirectly show you if you have implemented the required
functionality correctly. Even if you have not started Part B you should make these changes
immediately.
THE TASK
Add the directive using System.IO; into the Die class (Die.cs)
Copy the following four lines into the Die class as class variables following the constants
declarations.
private static string defaultPath = Environment.CurrentDirectory;
private static string rollFileName = defaultPath + “\\testrolls.txt”;
private static StreamReader rollFile = new StreamReader(rollFileName);
private static bool DEBUG = false;
The body of the Roll() method is currently the following two lines:
faceValue = random.Next(NumOfFaces) + 1;
return FaceValue;
Replace those two lines with the following statements:
if (!DEBUG) {
faceValue = random.Next(NumOfFaces) + 1;
} else {
faceValue = int.Parse(rollFile.ReadLine());
}
return FaceValue;
Copy the supplied data file, testrolls.txt, into the Debug subdirectory of the bin subdirectory of Space
Race, see screenshot next page.
…\Space Race\Space Race\bin\Debug
Page 2 of 4
Also copy the data file into the Debug subdirectory of the bin subdirectory of GUI Class,
…\Space Race\GUI Class\bin\Debug
Build the Object Classes and rebuild the Game Logic Class and whatever class is your current StartUp
Project.
If your project played the Space Race Game correctly before making these changes, it will still play
correctly.
USING THE DATA FILE
If you think your Space Race Game is playing correctly you can use the data file to test it. However
the data does not attempt to cover all possibilities, for example no player runs out of fuel.
In the Die Class, change the initialisation of DEBUG to true.
Now run your Space Race Game. Selecting 6 players and playing two game. The following two
screenshots so the resulting Console output.
Page 3 of 4
Exit the program and rerun your project selecting 3 players and again playing two games. The
following two screenshots so the resulting Console output.
Page 4 of 4