A-level Computing 2009/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Skeleton code/2011 Exam/Section C
Discussion of the codeEdit
Potential questionsEdit
ValidationEdit
- List the Erroneous, Extreme and Typical Data for a user selecting a menu item:
A: | ||||||||||
In the exam you might be asked to give only one example of each
|
- List the Erroneous, Extreme and Typical Data for a manual bowling die:
A: | ||||||||||
In the exam you might be asked to give only one example of each
|
- List the Erroneous, Extreme and Typical Data for a manual appeal die:
A: | ||||||||||
In the exam you might be asked to give only one example of each
|
VariablesEdit
- Give the name of the identifier of a Constant
A: | ||
MaxSize |
- Give the name of the identifier of a global variable
A: | ||
MaxSize (even though this is a constant, it can still be counted as a variable and is the only global declaration) |
- Give the identifier of a local variable
A: | ||
you would only have to list one in the exam if asked this question
PlayerOneName, PlayerTwoName, OptionSelected, Count, PlayerName, OptionChosen, BowlDieResult, RunsScored, AppealDieResult, LowestCurrentTopScore, PositionOfLowestCurrentTopScore, Count (there are multiple of these), Count2, LineFromFile, PlayerOut, CurrentPlayerScore, AppealDieResult, PlayerNo, PlayerOneScore, PlayerTwoScore, BowlDieResult, RunsScored |
- Note the identifier of an array:
A: | ||
ValuesOnLine(2), TopScores(MaxSize) |
- Give the identifier of a user defined data type:
A: | ||
you might be asked to explain more about this, so revise structures (records)
TTopScore |
- Give an example of an assignment statement:
A: | ||
remember, assignments are where you give a variable a value
PlayerOneName = GetValidPlayerName(), TopScores(Count).Score = 0 |
- Give an example of a variable declaration:
A: | ||
there are dozens of these...
Dim Count As Integer |
- Why might we not want to store an average score as an integer?
A: | ||
An integer would not be suitable as an average score may include decimal values. |
LoopsEdit
- Give the name of a stepper variable used in a loop?
A: | ||
Count in the ResetTopScores procedure |
- Give the name of a fixed variable used in a loop?
A: | ||
MaxSize in the ResetTopScores procedure - But MaxSize is a constant not a variable! It can still be classed as a variable. |
- Give the name of a follower used in a loop?
A: | ||
??? |
- Give the name of a most recent holder used in a loop?
A: | ||
RunsScored in PlayDiceGame and LineFromFile in LoadTopScores |
Sub RoutinesEdit
- Write down a function declaration used in the program
A: | ||
Function GetValidPlayerName() As String |
- Write down a function call used in the program
A: | ||
PlayerOneName = GetValidPlayerName() ; PlayerTwoName = GetValidPlayerName() ; BowlDieResult = RollBowlDie(VirtualDiceGame) ; AppealDieResult = RollAppealDie(VirtualDiceGame). Make sure that you include the = as a function call will always return a value |
- Write down a procedure declaration used in the program
A: | ||
Sub ResetTopScores(ByRef TopScores() As TTopScore) |
- Give the name of a parameter used in a procedure
A: | ||
VirtualDiceGame, BowlDieResult, RunsScored, CurrentPlayerScore, etc. |
A: | ||
byRef refers to the original value that is passed to the sub routine, and any changes made to the value inside the subroutine are applied directly to the original value as well, byVal copies the value into another variable inside the subroutine and any changes made to this value are not made to the original |
- Why is Byref used in the ResetTopScores sub routine?
A: | ||
the routine wants to reset the Top Scores, as the top scores are not a global variable we use byRef to refer to the original value and any changes made to TopScores are made directly to the TopScores array |
- Write down where a return value for a function is assigned:
A: | ||
GetValidPlayerName = PlayerName, RollBowlDie = BowlDieResult, CalculateRunsScored = RunsScored |
Trace TablesEdit
- Construct a trace table for the ResetTopScores procedure when passed the following data:
Maxsize | Count | TopScores | |||||||
---|---|---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | ||||||
name | score | name | score | name | score | name | score | ||
4 | Peter | 23 | Michael | 65 | Aubrey | 24 | Marea | 89 | |
A: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|