Class Notes (1,100,000)
CA (630,000)
SFU (10,000)
IAT (200)
IAT 167 (30)
Lecture 5

IAT167-Week 5 Lecture 2.docx


Department
Interactive Arts & Tech
Course Code
IAT 167
Professor
Jack Stockholm
Lecture
5

This preview shows half of the first page. to view the full 2 pages of the document.
Week 5 Lecture 2
OOP Concepts
Encapsulation
Inheritance
Class Interfaces
Polymorphism
Encapsulation
The ability of an object to be a container for properties (data) and methods
The ability of an object to hide and restrict access to internal properties and methods
Accessor functions allow class consumers to read internal variables
Mutator functions allow class consumers to change internal variables
Example:
Object {
public var x:int;
public var y:int;
public function show();
}
Access Control
internal (default) - Visible to references inside the same package.
private - Visible to references in the same class.
protected - Visible to references in the same class and derived classes.
public - Visible to references everywhere.
static - Specifies that a property belongs to the class, as opposed to instances of the class.
Get / Set
Access a class variable via functions but as if directly
Allows you to put conditions on when getting and setting is allowed
Inheritance
The capability of a class to use the properties and methods of another class (its superclass)
while adding its own functionality (the subclass)
Example
class Wheel{
var hub;
var spokes;
var rim;
function roll();
}
class RearWheel extends Wheel {
var gears; function pedal();
You're Reading a Preview

Unlock to view full version