Computer Science · Oct / Nov 2023 · Paper 2 SL · Question 11
Adapt for 2027Writing Java methods, class versus object and OOP disadvantages are in B3.1; the UML relationships use the Higher Level multiple-classes topic. Includes Higher Level only content, which Standard Level students do not study.
IBCS
As printed in the paper
The question as text
11. 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
11(a)[4]
11(b)[4]
11(c)[2]
11(d)[5]
11(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.

