Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Programming B.Sc. Multimedia ComputingMultimedia Authoring.

Similar presentations


Presentation on theme: "Object Oriented Programming B.Sc. Multimedia ComputingMultimedia Authoring."— Presentation transcript:

1 Object Oriented Programming B.Sc. Multimedia ComputingMultimedia Authoring

2 Agenda Procedural Programming v OOP Software Objects Classes and Methods The Object Oriented Paradigm B.Sc. Multimedia ComputingMultimedia Authoring

3 Object Oriented Programming Object-Oriented Programming is a way of describing and structuring software systems that features objects that contain functionality and data Early program structure techniques kept program functionality and data separate - so called “procedural programming” B.Sc. Multimedia ComputingMultimedia Authoring

4 Procedural Programming 10 readln(sum) 20 sum = sum + x 30 writeln(“The answer is” ), sum). 60 GOSUB 200. 200 readln(answer). 300 return B.Sc. Multimedia ComputingMultimedia Authoring

5 Object Oriented Programming OOP places the data and functionality inside a software object - the data is siad to be encapsulated within the object B.Sc. Multimedia ComputingMultimedia Authoring Software object data and functionality

6 Object Oriented Programming Software objects communicate with other software objects to carry out the overall function of a software system by sending messages to each other B.Sc. Multimedia ComputingMultimedia Authoring Software object data and functionality Software object data and functionality

7 Transport System To model vehicles and drivers as an OOP software system think about the various objects, properties and functions of such a system: Vehicles - Type, Make, Model, Value, Registration Number Drivers - Name, Age, Date of Birth, License Type B.Sc. Multimedia ComputingMultimedia Authoring

8 Transport System: Vehicle Object: Vehicles Properties (attributes) Type Make Model Value Registration Number Functions (methods) Create an object of type Vehicle Set the Make of vehicle Get the make of vehilce Set the value of the vehicle B.Sc. Multimedia ComputingMultimedia Authoring

9 Transport System: Driver Object: Driver Properties (attributes) Name Date of Birth License Type Value Functions (methods) Create an object of type Driver Set the Name of a driver Get the name of a driver Set the type of license Get the type of license B.Sc. Multimedia ComputingMultimedia Authoring

10 Driver Object B.Sc. Multimedia ComputingMultimedia Authoring Driver Properties: Name Date of Birth License Type Set Name Get Name Set Date of Birth Get Date of Birth Functions (methods) to communicate with a Driver object

11 Vehicle Object B.Sc. Multimedia ComputingMultimedia Authoring Vehicle Properties: Make Model Registration No. Value Set Make Get Make Set Registration No. Get Registration No. Functions (methods) to communicate with a Vehicle object

12 Class Definition for a Vehicle B.Sc. Multimedia ComputingMultimedia Authoring public class Vehicle { // ------ constructor------ // public function Vehicle(){ } // end constructor // ------ properties ------ // var regNo:String; var make:String; var model:String; var saleValue:int;

13 Set Method Definition B.Sc. Multimedia ComputingMultimedia Authoring // ------- set the registration number ------- // public function setRegNumber(aRegNumber:String):void { this.regNo = aRegNumber; } // end setRegNumber

14 Get Method Definition B.Sc. Multimedia ComputingMultimedia Authoring // -------- get the registration number ------ // public function getRegNumber():String { var aRegNumber:String; aRegNumber = this.regNo; return aRegNumber; } // end getRegNumber

15 Class Instantiation and Method References B.Sc. Multimedia ComputingMultimedia Authoring var aCar:Vehicle = new Vehicle(); var reg:String; var make:String; aCar.setRegNumber("BKD 1"); aCar.setMake("Ferrari"); make = aCar.getMake(); reg = aCar.getRegNumber();

16 ActionScript 3.0 Implementation Details B.Sc. Multimedia ComputingMultimedia Authoring import uk.ac.uwe.multimedia.transport.Vehicle; var aCar:Vehicle = new Vehicle(); var reg:String; var make:String; aCar.setRegNumber("BKD 1"); aCar.setMake("Ferrari"); make = aCar.getMake(); reg = aCar.getRegNumber(); trace(make); trace(reg);

17 ActionScript 3.0 Implementation Details B.Sc. Multimedia ComputingMultimedia Authoring import uk.ac.uwe.multimedia.transport.Vehicle; var aCar:Vehicle = new Vehicle(); var reg:String; var make:String; aCar.setRegNumber("BKD 1"); aCar.setMake("Ferrari"); make = aCar.getMake(); reg = aCar.getRegNumber(); trace(make); trace(reg);

18 Object Oriented Programming Features Classes are templates for objects, classes define properties and methods which dictate the state and behavior of the resulting software object Data and related functions are contained within the same object space - encapsulation Classes can be extended by creating subclasses which have similar properties and behaviors - inheritance Inherited behaviors can be modified (overridden) to change the way an object responds to common messages- polymorphism These three characteristics of OOP are often referred to as the “Object Oriented Paradigm” B.Sc. Multimedia ComputingMultimedia Authoring


Download ppt "Object Oriented Programming B.Sc. Multimedia ComputingMultimedia Authoring."

Similar presentations


Ads by Google