AQA A-Level Computer Science AS Paper 1, June 2025: Question 15
5 marks · Medium difficulty · Programming
Modify the Skeleton Program to record and display the total walking time for the pirate, adding a WalkTime field to PirateRecord and updating subroutines accordingly.
Practise this questionQuestion
Question text
15 This question extends the functionality of the Skeleton Program.
The Skeleton Program is to be changed so that the time the pirate spends walking is
recorded and displayed at the end of the game.
The subroutine PirateWalks needs to be modified so that a total of the time the
pirate walks is kept:
• walking one length N, E, S or W counts as 1.0 hours walking
• walking one length in a diagonal direction (NE, SE, SW, NW) counts as
1.4 hours walking.
At the end of the game, the total hours walked is to be output as part of the results.
What you need to do:
Task 1
In PirateRecord create an extra field WalkTime to store the number of hours
walked as a number with a fractional part value.
Initialise the value of WalkTime to 0.0 in the ResetPirateRecord subroutine.
Task 2
Amend the subroutine PirateWalks to calculate the time walked and update the
WalkTime field in the Pirate variable.
Task 3
Amend the subroutine DisplayResults to output the total time spent walking with
an appropriate message.
Task 4
Test that the changes you have made work by conducting the following test:
• run your amended Skeleton Program
• enter W
• enter 8NE
• enter W
• enter 9E 11
• press ENTER
Evidence that you need to provide
Include the following evidence in your Electronic Answer Document.
15.1 Your PROGRAM SOURCE CODE:
• for the entire subroutine ResetPirateRecord
• for the entire subroutine PirateWalks
• for the entire subroutine DisplayResults.
[4 marks]
15.2 SCREEN CAPTURE(S) showing the requested test described in Task 4.
The SCREEN CAPTURE(S) must show the map with the pirate’s final position as well
as the results.
[1 mark]
Mark scheme
Show the mark scheme
Qu Marks
15 1 4 marks for AO3 (programming) 4
Marking guidance:
Evidence of AO3 programming – 4 marks:
Evidence of programming to look for in response:
1. Field initialised in ResetPirateRecord;
2. Selection structure to detect all eight compass points;
3. Correct calculation of hours walked for all eight directions;
4. In DisplayResults output number of hours walked with suitable message;
Max 3 if any errors
15 2 Mark is for AO3 (evaluate) 1
**** SCREEN CAPTURE ****
Must match code from 15.1, including prompts on screen capture matching those in
code.
Code for 15.1 must be sensible.
Screen capture showing:
012345678901234567890123456789012345678901
0 WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
1 WWWWWWW … WWWWWWWWWW
2 WWWWW … WWWWWWWW N
3 WWWW … WWWWWW NW | NE
4 WW … R … WWWW \ | /
5 W … WWW W -----|----- E
6 W … WW / | \
7 W … *..*...* … W SW | SE
8 W … W S
9 W … * … * … H … W
0 W … * … P … W
1 W … * … * … W
2 WW … BBWW
3 WWW … BBWWW
4 WWWWW … BBBBBB...BBWWWW
5 WWWWWW … BBWWWWWBBBBWWWWW
6 WWWWWWW … BBBWWWWWWWWWWWWWWWW
7 WWWWWWWWWW … BBWWWWWWWWWWWWWWWWWW
8 WWWWWWWWWWW … X … BBWWWWWWWWWWWWWWWWWWW
9 WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
Pirate to walk (W) or dig (D), to finish game press Enter:
0.0 hours spent digging
20.2 hours spent walking – – –
The score is 90
Press Enter to finish
15 1 Sub ResetPirateRecord(ByRef Pirate As PirateRecord) 4 13
Pirate.Row = 0
Pirate.Column = 0
Pirate.Score = 100
Pirate.DigTime = 0.0
Pirate.TreasureFound = False
Pirate.NumberOfCoinsFound = 0
Pirate.WalkTime = 0.0 ' MP1 Task 1
End Sub
Sub PirateWalks(Map(,) As String, MapSize As MapSizeRecord,
HiddenMap(,) As String, ByRef Pirate As PirateRecord)
Dim ObstacleInPath As Boolean = True
Dim ValidDistance As Boolean = False
Dim ValidDirection As Boolean = False
Dim WalkData, Direction As String
Dim Row, Column, NumberOfSquares As Integer
While ObstacleInPath Or Not ValidDistance Or Not ValidDirection
Console.Write("Enter length (1 to 9) and direction (N, NE, E, SE,
S, SW, W, NW): ")
WalkData = Console.ReadLine()
Row = Pirate.Row
Column = Pirate.Column
ValidDistance = CheckDistance(WalkData(0), NumberOfSquares)
Direction = WalkData.Substring(1)
ValidDirection = CheckDirection(Direction, Row, Column,
NumberOfSquares)
If Row >= MapSize.Rows Or Column >= MapSize.Columns Or Row < 0 Or
Column < 0 Then
ValidDirection = False
Console.WriteLine("Error")
End If
If ValidDirection Then
ObstacleInPath = CheckPath(Map, Pirate.Row, Pirate.Column, Row,
Column, Direction)
If ObstacleInPath Then
Console.WriteLine("Pirate can't walk this way as there is an
obstacle in the way")
End If
End If
End While
Move(Map, MapSize, Pirate, Row, Column)
If Len(Direction) = 1 Then
Pirate.WalkTime += NumberOfSquares ' MP2
Else
Pirate.WalkTime += NumberOfSquares * 1.4 ' MP3 Task 2
End If
End Sub
Sub DisplayResults(Pirate As PirateRecord)
If Pirate.NumberOfCoinsFound > 0 Then
Console.WriteLine(
quot;{Pirate.NumberOfCoinsFound} gold coins found")End If
Console.WriteLine(
quot;{Pirate.DigTime:N} hours spent digging")Console.WriteLine(
quot;{Pirate.WalkTime:N} hours spent walking") ' MP4Task3
Console.WriteLine(
quot;The score is { Pirate.Score }")End Sub
– – –
15 1 public static void ResetPirateRecord(ref PirateRecord pirate) 4
20 {
pirate.row = 0;
pirate.column = 0;
pirate.score = 100;
pirate.digTime = 0.0;
pirate.treasureFound = false;
pirate.numberOfCoinsFound = 0;
pirate.walkTime = 0.0; // MP1 Task 1
}
static void PirateWalks(string[,] map, MapSizeRecord mapSize,
string[,] hiddenMap, ref PirateRecord pirate)
{
bool obstacleInPath;
bool validDistance;
bool validDirection;
string walkData;
string direction = "";
int row = 0;
int column = 0;
int numberOfSquares = 0;
obstacleInPath = true;
validDistance = false;
validDirection = false;
while (obstacleInPath || !validDistance || !validDirection)
{
Console.Write("Enter length (1 to 9) and direction (N, NE,
E, SE, S, SW, W, NW): ");
walkData = Console.ReadLine();
row = pirate.row;
column = pirate.column;
(validDistance, numberOfSquares) =
CheckDistance(walkData[0].ToString());
direction = walkData.Substring(1);
(validDirection, row, column) = CheckDirection(direction,
row, column, numberOfSquares);
if (row >= mapSize.rows || column >= mapSize.columns ||
row < 0 || column < 0)
{
validDirection = false;
Console.WriteLine("Error");
}
if (validDirection)
{
obstacleInPath = CheckPath(map, pirate.row,
pirate.column, row, column, direction);
if (obstacleInPath)
{
Console.WriteLine("Pirate can't walk this way as there
is an obstacle in the way");
}
}
} – – –
Move(map, mapSize, ref pirate, row, column);
if (direction.Length == 1) // Task 2
30 {
pirate.walkTime += numberOfSquares; // MP2
}
else
{
pirate.walkTime += 1.4 * numberOfSquares;– // MP3– –
}
}
15 1 void ResetPirateRecord(PirateRecord Pirate) {
Pirate.Row = 0;
Pirate.Column = 0;
Pirate.Score = 100;
Pirate.DigTime = 0.0f;
Pirate.TreasureFound = false;
Pirate.NumberOfCoinsFound = 0;
Pirate.WalkTime = 0.0f; // MP1 Task 1
}
void PirateWalks(String[][] Map, MapSizeRecord MapSize, String[][]
HiddenMap, PirateRecord Pirate) {
boolean ObstacleInPath = true;
boolean ValidDistance = false;
boolean ValidDirection = false;
int Row = 0, Column = 0, NumberOfSquares = 0;
String Direction = "";
while (ObstacleInPath || !ValidDistance || !ValidDirection) {
Console.write("Enter length (1 to 9) and direction (N, NE, E, SE, S,
SW, W, NW): ");
String WalkData = Console.readLine();
Row = Pirate.Row;
Column = Pirate.Column;
MoveCheckRecord DistanceData =
CheckDistance(String.valueOf(WalkData.charAt(0)));
ValidDistance = DistanceData.valid;
NumberOfSquares = DistanceData.numberOfSquares;
Direction = WalkData.substring(1);
MoveCheckRecord DirectionData = CheckDirection(Direction, Row, Column,
NumberOfSquares);
ValidDirection = DirectionData.valid;
Row = DirectionData.row;
Column = DirectionData.column;
if (Row >= MapSize.Rows || Column >= MapSize.Columns || Row < 0 ||
Column < 0) {
ValidDirection = false;
Console.writeLine("Error");
}
if (ValidDirection) {
ObstacleInPath = CheckPath(Map, Pirate.Row, Pirate.Column, Row,
Column, Direction);
if (ObstacleInPath) {
Console.writeLine("Pirate can't walk this way as there is an
obstacle in the way");
}
}
}
Move(Map, MapSize, Pirate, Row, Column);
if (Direction.length() == 1) {
Pirate.WalkTime += NumberOfSquares; // MP2 Task 2
} else {
Pirate.WalkTime += 1.4 * NumberOfSquares; // MP3 Task 2
}
} 31
void DisplayResults(PirateRecord Pirate) {
if (Pirate.NumberOfCoinsFound > 0) {
Console.writeLine(Pirate.NumberOfCoinsFound– + " gold coins– found");–
}
Console.writeLine(Pirate.DigTime + " hours spent digging");
Console.writeLine(Pirate.WalkTime + " hours spent walking"); // MP4
Task3
Console.writeLine("The score is " + Pirate.Score); 37
}
Alternative answer 1 for mark points 2 and 3:
if ("NSEW".contains(Direction)) {
Pirate.WalkTime += NumberOfSquares;
} else {
Pirate.WalkTime += 1.4 * NumberOfSquares;
}
Alternative answer 2 for mark points 2 and 3:
if (Direction == "N" || Direction == "S" || Direction == "E" || Direction ==
"W") {
Pirate.WalkTime += NumberOfSquares;
} else {
Pirate.WalkTime += 1.4 * NumberOfSquares;
}
How to answer it
Skeleton Program: Tracking Total Walking Time (Question 15)
This practical programming task assesses your ability to adapt an existing codebase (the Paper 1 Skeleton Program) by:
- Extending Data Structures (Records/Classes): Adding a fractional (floating-point/real) field to a composite type.
- Subroutine Initialisation: Correctly setting base values inside reset routines.
- Selective Logic: Distinguishing between cardinal movement (1 character: N, S, E, W) and diagonal movement (2 characters: NE, NW, SE, SW).
- Accumulator Arithmetic: Applying differing rate multipliers (1.0 vs 1.4 hours per square) to calculate running totals.
- Formatted Output & Testing: Displaying descriptive summaries and generating specific evidence via systematic execution.
Source Code Amendments: Subroutines Implementation
4 Marks [AO3 Programming]
✅ Correct Code Implementations
You must modify the record definition (e.g. WalkTime: real / double / float ) and the following three subroutines:
1. ResetPirateRecord:
// VB.NET / C# / Java / Python equivalent Pirate.WalkTime = 0.0 ' [MP1] Initialise to 0.0 2. PirateWalks (Calculation logic after movement):
' MP2 & MP3: Check direction length or match direction strings If Len(Direction) = 1 Then Pirate.WalkTime += NumberOfSquares ' 1.0 hr per square Else Pirate.WalkTime += NumberOfSquares * 1.4 ' 1.4 hrs per square End If 3. DisplayResults (Reporting):
' MP4: Meaningful message with total hours Console.WriteLine(Pirate.WalkTime & " hours spent walking" ) 💡 Key Knowledge & Logic Tricks
- Length Detection Trick: Cardinal directions are always 1 character ( N , E , S , W ), while diagonals are always 2 characters ( NE , SE , SW , NW ). Checking Direction.Length == 1 eliminates tedious compound OR conditions.
- Data Type Selection: The mark scheme requires a fractional representation (e.g., Single , Double , float ). Using an integer will truncate decimal values like 1.4 and cost multiple marks.
- Accumulator Position: The calculation must occur only after a successful move is made (after the obstacle validation loop).
🧠 Exam Technique & Mark Breakdown
- MP1: Field initialised to 0.0 in ResetPirateRecord .
- MP2: Selection structure detects all 8 compass points (checking length or matching "NSEW" ).
- MP3: Correct accumulation using NumberOfSquares * 1.0 and NumberOfSquares * 1.4 for diagonals.
- MP4: In DisplayResults , outputting Pirate.WalkTime along with a clear context message (e.g. "hours spent walking" ).
❌ Common Student Errors
- Hardcoding 1 step: Writing WalkTime += 1.4 instead of multiplying by NumberOfSquares .
- Integer Division: Using integer variables or types causing 1.4 to round down to 1 .
- Missing Subroutines: Forgetting to paste all three required subroutines into the Electronic Answer Document (EAD).
- Placement: Updating WalkTime before obstacle checking, meaning the pirate accumulates time even when blocked.
Test Execution & Screen Capture
1 Mark [AO3 Evaluate]
📐 Calculation Check (Test Verification)
The test requires executing the following exact moves:
- Move 1: Walk 8NE (diagonal)
Calculation: 8 × 1.4 = 11.2 hours - Move 2: Walk 9E (cardinal)
Calculation: 9 × 1.0 = 9.0 hours - Total Expected Walking Time:
11.2 + 9.0 = 20.2 hours
✅ Required Terminal Output Evidence
The screenshot must show the updated grid and summary lines:
0.0 hours spent digging 20.2 hours spent walking The score is 90 Press Enter to finish Pirate Position: The pirate symbol ( P ) must appear at Row 0, Column 22 on the final rendered map grid.
❌ Why Students Lost the Evaluation Mark
- Cropped Screenshot: Failing to include the full map alongside the final text output. The examiner needs to see the final position of the pirate P .
- Discrepant Messages: The prompt message in the screenshot not matching the code submitted in 15.1.
- Rounding Anomalies: Displaying 20.200000000000003 without basic formatting (usually acceptable, but can cause mark loss if prompt string does not match).
Topics
4.1 Fundamentals of programming · 4.2 Fundamentals of data structures · 4.13 Systematic approach to problem solving · 4.1.1 Programming · 4.13.1 Aspects of software development
Question and mark scheme from the AQA A-Level Computer Science examination, AS Paper 1, June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.