1 / 18

Object Oriented Programming

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

lindley
Télécharger la présentation

Object Oriented Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented Programming Multimedia Authoring B.Sc. Multimedia Computing

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

  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” Multimedia Authoring B.Sc. Multimedia Computing

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

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

  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 Software object Software object data and functionality data and functionality Multimedia Authoring B.Sc. Multimedia Computing

  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 Multimedia Authoring B.Sc. Multimedia Computing

  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 Multimedia Authoring B.Sc. Multimedia Computing

  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 Multimedia Authoring B.Sc. Multimedia Computing

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

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

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

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

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

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

  16. ActionScript 3.0 Implementation Details 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); Multimedia Authoring B.Sc. Multimedia Computing

  17. ActionScript 3.0 Implementation Details 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); Multimedia Authoring B.Sc. Multimedia Computing

  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” Multimedia Authoring B.Sc. Multimedia Computing

More Related