This section describes the layout of the IEB Information Technology Grade 12 Practical Examination. It attempts to guide one through the examination, teaching the programming skills needed to accomplish each section of the examination. The programming examination is divided up into four sections, each of which will usually correspond to one (but sometimes 2) Java classes. Each section builds on the previous section. However, even if you cannot complete a previous section, you can still gain marks in the next section. After coding, you will typically end up with four or more classes, some of which you have to code from scratch and some of which they may give parts of it to you.
You will be asked to create the Parent class first, the Child class next, the Worker class and then to complete the Application class. Notice the black arrows. This shows which class is being used in another class. For instance, the Worker class is used in the Application class and the Parent class is used in the Worker class and the Child class is used in the Worker class. The big arrow between the Parent and Child class is to show the idea of inheritance. The Child class is a type of the Parent class. It inherits all the fields and methods of its parents.
The four sections which I will divide up the examination are as follows:
Basic Class Design - Creating base classes or Parent classes
Basic Class Inheritance – Creating Child classes
Arrays of Objects - The Worker Class
Using your code - The Application Class
After this section, you should be able to:
Understand a class layout and terminology
Create a simple base class from a class diagram
Read terms 1-9 in the Terminology Appendix to gain a greater understanding of the theory behind this section.
In this section you are going to learn how to create a base class. Another term for this class might be a parent class or super class. You can be asked to read a class diagram and create the class or you will be told what to do to create the class. Sometimes this class is given to you and you may need to add to it.
Consider the following class called Member which describes an ordinary member of a gym.
Since a class consists of fields and methods, so the class diagram is divided into two sections: the properties(fields) section and the methods sections. Consider the following example of a class diagram:
MammalSighting
Properties:
- sightingNo : integer
- lodgeNo : integer
- species : character
- sDescription : string
- valCode : string
Methods:
+ constructor(sightingNo : integer, lodgeNo: integer, species: character,
sDescription: String, valCode: String)
+ toString() : String
+ getLodgeNo : integer
The class is called MammalSighting as seen in the first block in the diagram. This means that your class must also be called MammalSighting.
The properties block shows all the field names of the class and their data types. It also tells us which access modifier (public, protected or private) must be used for each field.
A + symbol before the field name means the field is public.
A – symbol before the field name means the field is private.
A # symbol before the field name means the field is protected.
The method block tells us what methods the class must contain. It tells us what access modifier to use for each method, the method name, the parameters that are passed to the method as well as the return type of the method – if it is not a void method.
The code that corresponds to the MammalSighting class is shown below: