Programming techniques
Programming techniques
Is where you group data and methods like attributes and functions and put them in a class.
This is where you hide data needed to make the program from users, to make sure that
no objects are modified or changed.
It is a feature that allows you to inherit certain characteristics without rewriting the code
for it.
1
Homework 6 Object oriented programming
Unit 11 Programming techniques
2. An object-oriented program is to be used to store and display details of members of a
sports club.
A member class is defined which holds attributes surname, first name, annual membership
fee, and methods to amend and display these details.
A junior member class inherits the attributes and methods of the member class but has an
additional attribute date of birth.
An incomplete definition of the Member class is given below.
Complete the statements where indicated. [3]
class Member
private surname
private firstname
private annualFee
public procedure new(mySurname, myFirstName, myAnnualFee)
(complete procedure here)
super.new(surnameVal,firstnameVal,annualfeeVal)
endprocedure
2
Homework 6 Object oriented programming
Unit 11 Programming techniques
(other procedures – do not complete)endclass
3
Homework 6 Object oriented programming
Unit 11 Programming techniques
(b) Write a statement to instantiate a junior member called Harry Mason, born 12/12/2004,
annual fee £25.00. [1]
newJunior(“Harry”,“Mason”,”12/12/2004”,£25.00)
(c) Write a method which will amend the annual fee of a junior member. [2]
myAnnualFee=£25.00
(d) Write a method which will return the date of birth of a junior member. [2]
print(“DOB”)
[Total 20 marks]