0% found this document useful (0 votes)
2 views

Programming techniques

The document outlines Homework 6 on object-oriented programming, focusing on key concepts such as encapsulation, data hiding, instantiation, inheritance, and polymorphism. It includes a practical exercise to define a Member class and a JuniorMember class, along with tasks to complete class constructors and methods. Additionally, it provides examples of instantiating a junior member and methods for amending details and retrieving information.

Uploaded by

fathiaadebambo08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Programming techniques

The document outlines Homework 6 on object-oriented programming, focusing on key concepts such as encapsulation, data hiding, instantiation, inheritance, and polymorphism. It includes a practical exercise to define a Member class and a JuniorMember class, along with tasks to complete class constructors and methods. Additionally, it provides examples of instantiating a junior member and methods for amending details and retrieving information.

Uploaded by

fathiaadebambo08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Homework 6 Object oriented programming

Unit 11 Programming techniques

Homework 6: Object oriented programming

1. In object-oriented programming, what is meant by the following terms?

(a) Encapsulation [2]

Is where you group data and methods like attributes and functions and put them in a class.

(b) Data hiding [2]

This is where you hide data needed to make the program from users, to make sure that
no objects are modified or changed.

(c) Instantiation [2]

It is the process of creating a new object from the class.

(d) Inheritance [2]

It is a feature that allows you to inherit certain characteristics without rewriting the code
for it.

(e) Polymorphism [2]


It is a feature that allows you to change certain methods that an object has from a
certain group.e.g. cat and a dog are from the same category animal. Animal might have
a method that gets given to each animal.Polymorphism stops them from having that
method or overriding 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)

public procedure amendDetails(mySurname, myfirstname,


myAnnualFee)
(leave this procedure incomplete)
endprocedure
(other procedures – do not complete)
endclass

(a) Complete the definition of the JuniorMember class constructor. [2]


class JuniorMember
private dateOfBirth
public procedure new(mySurname, myFirstname, myAnnualFee,
myDateOfBirth)

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]

You might also like