Past-paper question · 2018 May-June · Paper 43 · Q5(c)

Question 5(c) 2018 · May-June · Paper 43 · 6 marks

Original past-paper question for 5(C)
Original past-paper question for 5(C)
Original past-paper question for 5(C)
Original past-paper question for 5(C)
Original past-paper question for 5(C)
Reveal official mark-scheme answer Official mark-scheme answer for 5(C)Official mark-scheme answer for 5(C)Official mark-scheme answer for 5(C)

Official answer for Question 5

Part (c)

Question 6

✓
1 mark per bullet to max 4
✓
•
✓
class declaration with inheritance
✓
•
✓
constructor declaration
✓
•
✓
«taking all 5 parameters and CauseDamage, DamagePoints parameters
✓
•
✓
«with inheritance constructor call
✓
•
✓
Declaring CauseDamage, DamagePoints private and assigning parameters
✓
1 mark per bullet to max 4
✓
•
✓
Function declaration for GiveDamagePoints «
✓
•
✓
«checking if CauseDamage = True
✓
•
✓
«returning DamagePoints if true
✓
•
✓
«else returning appropriate value e.g. -1/null/blank
✓
Python example code:
✓
class Scenery(GameElement):
✓
def __init__(self, PositionX, PositionY, Width, Height,
✓
ImageFilename, CauseDamage, DamagePoints):
✓
Object.__init__(self, PositionX, PositionY, Width, Height,
✓
ImageFilename)
✓
self.__CauseDamage = CauseDamage
✓
self.__DamagePoints = DamagePoints
✓
def GiveDamagePoints(self):
✓
if(self.__CauseDamage):
✓
return self.__DamagePoints
✓
else:
✓
return 0
✓
9608/43
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2018
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s18_ms_43.pdf →

Show text version of question

Question 5

Part (c)

Question 5

A computer game is being developed using object-oriented programming. The following image is

a screenshot from the game.

There are scenery elements and animated elements. The player’s character is one of the animated elements.

Each game element has the attributes:

Attribute Description Example value The x coordinate of the game PositionX 92 element. The y coordinate of the game PositionY 106 element. Width The width of the game element. 150 Height The height of the game element. 200 The filename of the image file for ImageFilename GameElementFrame1.png the game element.

Each game element has a method, GetDetails() that returns a string containing all the element’s attributes.

The player’s character is one of a number of animated elements. All animated elements have the attributes:

Attribute Description Example value AnimationFrames An array of GameElement

A
string giving the direction the "Left"

Direction object is travelling in.

A
value for the strength that 2000

Strength indicates the power of the object.

A
value for the health that 100

Health indicates the health of the object.

The player’s character can either move left or right, or jump.

Question 11

Part (c)

The Scenery() class has two attributes, CauseDamage and DamagePoints.

If the attribute CauseDamage is TRUE, then the scenery element can cause damage.

The method GiveDamagePoints() checks whether the object can cause damage. If the object can cause damage, the method returns the integer value of the DamagePoints attribute.

Write program code for the Scenery class.

Programming language ............................................................................................................

Program code

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

Question 14

Topic relevance

Why this question appears here

98% assigned-topic match · Further programming › Programming paradigms

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_s18_qp_43.pdf

Keep practising this topic