A-level Computing/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Skeleton code/2012 Exam/Section C

Validation
Typical = 3 Extreme = 9,4 or 1

Erroneous = 7

Typical = N,S,E or W

Extreme = N,S,E or W

Erroneous = I

Variables
NoOfTraps, NSDistance, WEDistance

Improves readability of code // Easier to update the programming code if the value changes ( A. by implication) // reduce the likelihood of errors;

NoOfTraps, NSDistance, WEDistance

Choice

Cavern, TrapPositions

GameData, CellReference

ResetCavern(ByRef Cavern As Char);

Cavern(NSDistance, WEDistance);

Count; Count1; Count2;

SetUpGame; Cavern, TrapPositions, MonsterPosition, PlayerPosition, FlaskPosition, MonsterAwake, NewGame

Const NoOfTraps = 2

Choice = GetMainMenuChoice

Dim MonsterAwake As Boolean (Pascal) Choice : Integer; FlaskPosition : TCellReference; MonsterAwake : Boolean; MonsterPosition : TCellReference; PlayerPosition : TCellReference; TrapPositions : TTrapPositions;

The answer may be a decimal

Loops
Count1, Count2, Count

NSDistance, WEDistance

Choice MAY be an answer here.

FlaskPosition may be a recent holder(?). See 'MoveFlask' sub-routine. I think it is because the program holds the flask ("F") in the 'FlaskPosition' cell reference until the 'NewCellForFlask' variable can hold "F" (after which FlaskPosition changes to " "):

To check each element of the array by progressing firstly along the columns, then down to the next row and to continue until the end of the array is reached;

The loop end is known when the loop is created and therefore has a known number of steps; the loop does not depend upon an event where the occurrence of that event is unknown;

Sub Routines
Function GetMainMenuChoice As Integer

Choice = GetMainMenuChoice

Sub DisplayMenu

Cavern

When a parameter is passed byRef, the variable inside the routine uses a reference to the same memory location as the variable passed as the parameter. When a parameter is passed byVal, the variable inside the routine copies the value of the calling code's variable to the routine's parameter.

Can't find the ResetTopScores sub routine!! If there was one, it would use byRef so that when the scores are reset in the sub-routine, the changes to the variable remain in the whole program and not within that particular sub-routine alone.

GetMainMenuChoice = Choice

ValidMove; Is set to TRUE initially and remains so if the move made is considered valid but is changed to FALSE if considered invalid. This flag is then parsed as the final value back to the calling routine;