Computer Science · Oct / Nov 2023 · Paper 2 SL · Question 10
Adapt for 2027Static, private variables, accessors and creating objects are taught, but the open source movement part is no longer on the syllabus. Includes Higher Level only content, which Standard Level students do not study.
IBCS
As printed in the paper
The question as text
10. A company that manufactures a children’s card game, Monster Battle, wants to create a software version. Figure 7 shows three sample cards from the game. Figure 7: Three sample cards from Monster Battle NAME: SPLASHY WATER MONSTER TYPE: 25 HEALTH POINTS: HEAL A FRIEND SPECIAL ABILITIES: 1. PUT OUT FIRE 2. SOAK 3. NAME: SQUISHY WATER MONSTER TYPE: 20 HEALTH POINTS: HEAL A FRIEND SPECIAL ABILITIES: 1. PUT OUT FIRE 2. CLEAN 3. NAME: FLAMEY FIRE MONSTER TYPE: 40 HEALTH POINTS: HEAL A FRIEND SPECIAL ABILITIES: 1. HEAT WATER 2. BURN 3. Each monster begins the game with a number of health points, which are stated on the card, and leaves the game when it has no remaining health points. During a battle between two monsters, players take turns to roll the dice. The results determine how much each monster’s attack will reduce the defending monster’s health points. Some initial classes have been created to model this scenario. public class Monster { public static final int ICE_MONSTER_TYPE = 1; public static final int WATER_MONSTER_TYPE = 2; public static final int FIRE_MONSTER_TYPE = 3; public String name = "Unknown"; public int health = 100; public int strength = 10; public int monsterType = 0; public Monster(String name, int health, int monsterType) { this.name = name; this.health = health; this.monsterType = monsterType; } public void attack(Monster defender) { //to be written } (Option D continues on the following page) (Option D, question 10 continued) private static int rollDice() { //returns a random integer between 1 and 12 return new java.util.Random().nextInt(12)+1; } public static void output(String message) { System.out.println(message); } } public class WaterMonster extends Monster { public WaterMonster(String name, int health) { super(name,health, Monster.WATER_MONSTER_TYPE); } } public class FireMonster extends Monster { public FireMonster(String name, int health){ super(name, health, Monster.FIRE_MONSTER_TYPE); } }
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
10(a)[1]
10(b)(i)[2]
10(b)(ii)[2]
10(c)[2]
10(d)[2]
10(e)[2]
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

