(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
9608/41/M/J/15
4 A payroll program is to be written using an object-oriented programming language. An
[3]
(b) The design for the Employee class consists of:
properties
o EmployeeName
o EmployeeID
o AmountPaid
o ThisMonth
methods
o SetEmployeeName
o SetEmployeeID
o CalculatePay
Write program code for the class definition of the superclass Employee.
Programming language
.............................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [5]
(c) (i) State the properties and/or methods required for the subclass
HourlyPaidEmployee.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
(ii) State the properties and/or methods required for the subclass SalariedEmployee.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(d) Name the feature of object-oriented program design that allows the method
...................................................................................................................................................
.............................................................................................................................................. [1]
9608/43/M/J/15
Q4 A sports club stores data about its members. A program is to be written using an
object-oriented programming language.
FullMember
JuniorMember
[3]
Write program code for the class definition of the superclass Member.
Programming language
...................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.....................................................................................................................................................[5]
(c) Additionally a DateOfBirth property is required for the JuniorMember class.
(i) Write program code for the class definition for the subclass JuniorMember.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
(ii) Write program code to create a new instance of JuniorMember.
Use identifier NewMember with the following data:
name Ahmed with member ID 12347, born on 12/11/2001, who has paid his subscription.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
9608/42/M/J/18
Q4 X-Games is an international extreme sports competition. A program will store and
process data about the teams in the competition.
Each team is made up of members.
Members can be added and removed from each team.
Each member has a first name, last name, date of birth and gender.
Each member can be an official or a competitor.
Each official has a job title and may be first-aid trained.
Each competitor takes part in one sport.
The program is written using object-oriented programming. The program can output the
full name and date of birth of any member. For example, “Nadia Abad 16/05/1995”
An introduction about a team member can be output using their name. For example,
“Hello, I’m Nadia Abad”.
The program outputs a different version of the introduction for a competitor. This version
includes the competitor’s sport. For example, “Hello, I’m Sally Jones and my sport is
Skateboard Park.”
(a) Complete the following class diagram to show the attributes, methods and
inheritance for the program.
You do not need to write the get and set methods.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[5]
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[5]
(d) Omar Ellaboudy is an official at X-Games. He is first-aid trained and his job title is Judge. He
is male and was born on 17/03/1993.
Write program code to create an instance of an object with the identifier BMXJudge.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
9608/43/M/J/18
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:
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:
(a) Complete the following class diagram for the game. You do not need to include any
additional get or set methods.
[3]
(b) Write program code to define the GameElement class.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
(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]
Programming language
.....................................................................................................
Program code
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(ii) An additional method, GetScenery(), returns all the attributes of the Scenery
class.
Write program code for the GetScenery() method. You should use the GetDetails()
method that the Scenery class inherits from the GameElement class.
Programming language
.....................................................................................................
Program code
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]