Computer Science · Oct / Nov 2023 · Paper 2 HL · Question 18
IBCS
As printed in the paper
The question as text
18. The arena will maintain a linked list of the battles that take place between monsters, called gameLog. Each time a player takes a turn and one monster attacks another, a new instance of the Turn class is created and added to the gameLog linked list: public class Turn { long timestamp; Monster from; Monster to; int damage; } The developer wants to add a rewindTurns method in the Arena class, which restores health points taken from a particular monster during a specified number of turns. This method can be called at any time and will leave the gameLog linked list unchanged (see Figure 10). Figure 10: The gameLog linked list Timestamp: 01 From: Windy To: Flamey Damage: 11 Timestamp: 02 From: Flamey To: Windy Damage: 4 Timestamp: 03 From: Windy To: Flamey Damage: 1 Timestamp: 04 From: Flamey To: Windy Damage: 4 H The variable rewinder is a reference to a monster named Windy, which is battling another monster, Flamey. The game has had four attacks so far, each of which are entered in the gameLog linked list. In this example, the code rewindTurns(2, rewinder) would restore 4 health points to Windy, and the code rewindTurns(3, rewinder) would restore 8 health points to Windy.
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
18(a)[4]
18(b)[6]
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

