(P4) (4.3.1 Object Oriented Programming) Topical Past Papers

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

(P4) (4.3.

1 Object Oriented Programming) Topical Past Papers


Topical Past Paers 9608
with Sir Majid Tahir

Past Papers May/June 2015 to 2018:

9608/41/M/J/15
4 A payroll program is to be written using an object-oriented programming language. An

Employee class is designed. Two subclasses have been identified:

HourlyPaidEmployee who is paid a monthly wage calculated from their hourly


rate of pay and the number of hours worked during the month.
SalariedEmployee who is paid a monthly wage which is one 12th of their
annual salary (a) Draw an inheritance diagram for these classes.

(a) Draw an inheritance diagram for these classes.

[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

www.majidtahir.com Contact: 03004003666 Email: [email protected]


1
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

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]

www.majidtahir.com Contact: 03004003666 Email: [email protected]


2
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

(d) Name the feature of object-oriented program design that allows the method

CalculatePay to be declared in the superclass Employee.

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

.............................................................................................................................................. [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.

A Member class is designed. Two subclasses have been identified:

FullMember
JuniorMember

(a) Draw an inheritance diagram for these classes.

[3]

(b) The design for the Member class consists of


Properties
o MemberName
o MemberID
o SubscriptionPaid
Methods
o SetMemberName
o SetMemberID
o SetSubscriptionPaid

www.majidtahir.com Contact: 03004003666 Email: [email protected]


3
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

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.

www.majidtahir.com Contact: 03004003666 Email: [email protected]


4
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

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.

(b) Write program code for the Member class.


Programming language ............................................................................................................
Program code

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

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

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

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

www.majidtahir.com Contact: 03004003666 Email: [email protected]


5
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

...............................................................................................................................................[5]

(c) Write program code for the Competitor class.

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

Program code

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

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

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

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

www.majidtahir.com Contact: 03004003666 Email: [email protected]


6
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

...............................................................................................................................................[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.

All attributes of the instance must be fully initialised.

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

Program code

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

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

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

www.majidtahir.com Contact: 03004003666 Email: [email protected]


7
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

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

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

...............................................................................................................................................[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:

www.majidtahir.com Contact: 03004003666 Email: [email protected]


8
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

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

(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.

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

www.majidtahir.com Contact: 03004003666 Email: [email protected]


9
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

Program code

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

www.majidtahir.com Contact: 03004003666 Email: [email protected]


10
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

(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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

www.majidtahir.com Contact: 03004003666 Email: [email protected]


11
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

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

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

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

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

(d) A new scenery object, GiftBox, is to be created.


(i) The attributes of GiftBox are as follows:

Write program code to create an instance of GiftBox.

Programming language

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

Program code

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

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

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

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

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

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

.......................................................................................................................................[3]

www.majidtahir.com Contact: 03004003666 Email: [email protected]


12
(P4) (4.3.1 Object Oriented Programming) Topical Past Papers
Topical Past Paers 9608
with Sir Majid Tahir

(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]

www.majidtahir.com Contact: 03004003666 Email: [email protected]


13

You might also like