Computer Science · Oct / Nov 2023 · Paper 2 HL · Question 15
IBCS
As printed in the paper
The question as text
15. The Monster class contains the method attack(Monster defender). This is used when a monster attacks another monster (the defender). This method: y decreases the health variable of the defending monster by the amount returned by the rollDice method y uses the output method to display a defending monster’s name, damage and health points if its health variable is greater than zero y sets the defending monster’s health variable to zero if it is less than zero y outputs the defending monster’s name followed by “must leave the game” if its health variable is zero.
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
15(a)[4]
15(b)[4]
15(c)[2]
15(d)[5]
15(e)[4]
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

