Introduction to ActionScript 3.0 programming Object Oriented Programming pt. 1 & 2
|
|
- Sharleen Rogers
- 6 years ago
- Views:
Transcription
1 Introduction to ActionScript 3.0 programming Object Oriented Programming pt. 1 & 2 Thomas Lövgren Flash developer, designer & programmer thomas.lovgren@humlab.umu.se Umeå Institute of Design,
2 Introduction to ActionScript 3.0 OOP Lecture outline In this lecture we ll discuss and practice the following topics: OOP: Introduction, Planning & Design Classes and Objects Properties Constructor Create a Class file/test it Parameters and get/set methods Encapsulation Inheritance Polymorphism Examples of OOP usage
3 Introduction to OOP What is OOP? Object Oriented Programming is a type of programming which is oriented around objects - a technique to reuse code and decrease code maintenance Why OOP? As applications grow, structured programming gets unwieldy, and you'll be best advised to use an Object Oriented approach When should I use Object Oriented? There s no given rule for this, but in general for large projects (project-teams, many programmers), specific/advanced tasks, extended functionality/libraries etc. For small/basic projects it s probably not worth it, cause OOP planning, design and implementation takes time
4 OOP Planning & Design OOP is a programming paradigm where we can plan, design and use abstraction to create models based on the real world The object-oriented program design involves: Identifying the components of the system or application that you want to build Analyzing and identifying patterns to determine what components are used repeatedly or share characteristics Classifying components based on similarities and differences
5 Classes & Objects The concept of Classes and Objects is an important part in AS3, basically the whole language package is based on various classes So, what is a Class? What is an object? A class is a self-contained description for a set of services and data The class describes the final product (House). To actually do something; we need an Object (House Object) If the class is the House-blueprint, then the Object is the House We can write one class, then create as many Objects we want from that class (with unique properties) Objects are often referred to as Class Instances
6 Properties Properties are a collection of attributes that describes an object; For example, an Apple can have properties like color, size and position In a Class file, properties are variables/attributes that we can access and manipulate, for example like: var xpos:number = 200; xpos = 200 ypos = 200 Height = 300 Color = red
7 Create a New Object/Instance: Properties & methods Here is an example of how we can create a new Dog Object from the Dog class From the Dog class we can create as many new Dog Objects/Instanaces (with unique properties if we want) A Base class (top level class), is also called Super class Methods are very similar to Functions but tied to an object (inside a class) By accessing Methods; we can get data and/or change the properties of an object
8 Packages & Class Paths Packages are folder namespaces where we can store our classes, and give them an unique identifier we can use them to sort classes by function and make the import of classes easier Sometimes we need to import external classes, for the Tween class package it looks like this: import fl.transitions.tween; import fl.transitions.tweenevent; import fl.transitions.easing.*; The class path is made up of your domain name in reverse (this makes sure that the class path is unique), for example like: com.interactiondesign.data
9 Constructor A Constructor is a public method that has the same name as our class (defines our class) and is used to create new instances of our class (by using the new keyword) Any code that we include in our Constructor method is executed when a new instance of the class is created Example of a Constructor for the class Ball //example of a constructor public function Ball():void{ trace("ball constructor in the Ball class"); Note! If we don t define a constructor method in our class, the compiler will automatically create an empty constructor for us
10 Create The Class file First, in the Flash Main menu we select New ActionScript file (.as) The Package Keyword in the class file is a mandatory structure that ensures that our class file is known to the compiler In the example below we inherit (extends) properties & methods from the movieclip class Our Ball-class can also have additional methods package{ //define package import flash.display.movieclip; //import movieclip class public class Ball extends MovieClip{ //define our class //constructor for our class public function Ball():void{ //end package/class trace("ball class created!"); //output Note! We must save the class-file to actually se the result/updates!
11 Testing The Class file Create a new Flash AS3 File In the Main Timeline, write the following code: var ball_mc:ball = new Ball(); //create a new ball object addchild(ball_mc); //add to display list trace(ball_mc); //traces "Ball class created!" Note! The Ball class has only one method, containing the trace-command
12 Adding a Symbol Instance: add/link a MovieClip to our class If we want to add/link a MovieClip to our Ball-class it could be done like this: 1. Create a MovieClip and give it the name ball_mc 2. Right Click on the ball_mc in Library, setup Linkage in the properties-panel 3. Then check the box Export for ActionScript 4. Now the MovieClip is Linked to our Ball-class and will automatically be attached from library at runtime
13 Instance Parameters: create new objects with unique properties We can also create new Objects with unique properties, by sending parameters to the class constructor, part of the code looks like this: //a part of the class file (Ball.as) //constructor for the Ball class, takes 3 parameters public function Ball(xPos:Number, ypos:number, scale:number):void{ x = xpos; y = ypos; scalex = scaley = scale; //in the main timeline (.fla file) or main class //create a new ball object, and send 3 parameters to constructor var ball_mc:ball = new Ball(200, 150, 2.5); addchild(ball_mc); //add to display list
14 Get and Set Methods: class file Get and Set Methods (getters and setters) can be used to access and manipulate properties after an Object has been created var newspeed:number; //speed-variable in class //get and set methods for speed in class-file (Ship.as) public function getspeed():number{ return newspeed; //return speed public function setspeed(speed:number):void{ newspeed = speed; //set new value //in the main timeline (.fla file) or main-class //create a new ship object with speed 200 var ship:ship = new Ship(200); ship.getspeed(); //traces 200 ship.setspeed(350); //set new speed 350 ship.getspeed(); //traces 350
15 Document Class The Document class is a new feature in AS3, it s basically a Main class, that serves as an application entry point for our FLA/SWF When SWF s loaded, the Constructor of the Document class will be called A Document class extends Sprite or MovieClip class In the properties panel in the FLA file, we can define our Document class Note! This means that we necessarily don t need to have any code in the main timeline in our FLA file
16 Encapsulation: Hiding the details Encapsulation allows us to hide class properties and methods from other areas of our project, but still allows us to manipulate them in a controlled way (classes hide their own internal data) An Access modifier is a modifier that changes the visibility of a class or its members (variables, methods etc) In AS3 there are four different Access modifiers: Public: The public modifier provides access to external members Private: The private members are not exposed to external, instances or extended classes Protected: Access from sub-classes Internal: Public to classes in same package Note! In this lecture we are going to focus on the Public and the Private modifier
17 Inheritance (1/3): Avoid rebuilding the wheel With Inheritance a class can inherit or extend properties and methods from other classes (unless the properties and methods are marked as private) The Subclass (class that s inherit), can also add additional properties and/or methods, change some of the ones from the super/baseclass (the class that s being extended) The subclass can send received parameters up to the superclass, by using the super() command/method and also override inherited methods from the superclass by using the override keyword
18 Inheritance (2/3): Avoid rebuilding the wheel In this example we have two classes: A superclass called MySuperClass (see below) and a subclass called MySubClass - which inherit properties and methods from the superclass package{ //set up the superclass public class MySuperClass{ //declare class public function sayhello():void{ //method trace("hello from MyBaseClass"); //output package{ //set up the subclass (inheritance from superclass) public class MySubClass extends MySuperClass{ public function saygoodbye():void{ trace("goodbye from MySubClass"); //output //first frame in main timeline or main class var sub:mysubclass = new MySubClass(); //create a new subclass object sub.sayhello(); //call derived method from superclass sub.saygoodbye(); //call method in subclass
19 Inheritance (3/3): Avoid rebuilding the wheel If a class is derived from more than one superclass, the inheritance is called: Multiple Inheritance If a class is derived from a derived class, it s called: Multilevel Inheritance
20 Drawing/Graphics (Sprite): Circle Drawing class The constructor in this class takes one parameter (radius) and then draws a circle, the code looks like this: package{ import flash.display.sprite; //imports public class DrawCircle extends Sprite{ //extends with sprite private var circle:sprite; //declare sprite object private var newradius:number; //declare variable public function DrawCircle(radius:Number):void{ //constructor newradius = radius; //new radius from parameter circle = new Sprite(); //create new sprite object circle.graphics.beginfill(0xff0000); //fill graphics circle.graphics.drawcircle(300, 100, newradius); //draw circle.graphics.endfill(); //end fill addchild(circle); //add to display list
21 Polymorphism: Exhibiting similar features Polymorphism allows related classes to have methods that share the same name, but that behave differently when invoked By using polymorphism we can reduce the number of methods for our subclasses, which makes it easier to extend classes
22 UML Diagram UML (Unified Modeling Language) Diagram, is ideal for software engineers and software designers who need to draw detailed software design documentation There are quite a lot of UML-software s on the market, for example SmartDraw
23 The Tween Class: example of OOP usage The Tween class can be used for animations, in this case we only have to write 5 lines of code (someone have programmed the OOP part for us) So, to get this working, we only have to write like: //import classes import fl.transitions.tween; import fl.transitions.tweenevent; import fl.transitions.easing.*; //create the tween object, set up parameters var mytween:tween = new Tween(my_mc, "x", Elastic.easeOut, 30, 350, 3, true); mytween.start(); //start tween
24 Flash and Phidgets: example of OOP usage As an Interaction Designer you ll probably sometimes get in touch with Flash and Phidgets (sensors) AS3 has an OOP-based library for controlling different types of Phidgets, part of the code could look like this: //create a new phidget object var phid:phidgetinterfacekit = new PhidgetInterfaceKit(); //add listeners to object, event-connect, call onconnect method phid.addeventlistener(phidgetevent.connect, onconnect); phid.open("localhost", 5001, "", 65472); //open connection The Interactive Peace Creatures (2009)
25 Game development: example of OOP usage OOP is very often used in game development, for example a Space Game could have classes like: Spaceship Enemies Bullet Score
26 Summary: Benefits of OOP Analyzing user requirements Designing software Constructing software Reusability (reusable components) Reliability Robustness Extensibility Maintainability Reduces large problems to smaller, more manageable ones Fits the way the real world works; It is easy to map a real world problem to a solution in OOP code Project team: Split up work/responsibility into OOP parts
Introduction to ActionScript 3.0 programming MovieClips, properties & Display list
Introduction to ActionScript 3.0 programming MovieClips, properties & Display list Thomas Lövgren Flash developer, designer & programmer thomas.lovgren@humlab.umu.se Umeå Institute of Design, 2011-09-20
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationSoftware Development. Modular Design and Algorithm Analysis
Software Development Modular Design and Algorithm Analysis Data Encapsulation Encapsulation is the packing of data and functions into a single component. The features of encapsulation are supported using
More informationChapter 5 Object-Oriented Programming
Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares
More informationLecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance?
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 5: Inheritance & Polymorphism Lecture Contents 2 What is Inheritance? Super-class & sub class Protected members Creating subclasses
More informationObject Orientated Analysis and Design. Benjamin Kenwright
Notation Part 2 Object Orientated Analysis and Design Benjamin Kenwright Outline Review What do we mean by Notation and UML? Types of UML View Continue UML Diagram Types Conclusion and Discussion Summary
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 5: Inheritance & Polymorphism Lecture Contents 2 What is Inheritance? Super-class & sub class Protected members Creating subclasses
More informationInheritance and Polymorphism
Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4(b): Inheritance & Polymorphism Lecture Contents What is Inheritance? Super-class & sub class The object class Using extends keyword
More informationCREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed
CREATED BY: Muhammad Bilal Arslan Ahmad Shaad JAVA Chapter No 5 Instructor: Muhammad Naveed Muhammad Bilal Arslan Ahmad Shaad Chapter No 5 Object Oriented Programming Q: Explain subclass and inheritance?
More informationPROGRAMMING LANGUAGE 2
31/10/2013 Ebtsam Abd elhakam 1 PROGRAMMING LANGUAGE 2 Java lecture (7) Inheritance 31/10/2013 Ebtsam Abd elhakam 2 Inheritance Inheritance is one of the cornerstones of object-oriented programming. It
More informationChapter 5. Inheritance
Chapter 5 Inheritance Objectives Know the difference between Inheritance and aggregation Understand how inheritance is done in Java Learn polymorphism through Method Overriding Learn the keywords : super
More informationIT101. Inheritance, Encapsulation, Polymorphism and Constructors
IT101 Inheritance, Encapsulation, Polymorphism and Constructors OOP Advantages and Concepts What are OOP s claims to fame? Better suited for team development Facilitates utilizing and creating reusable
More information9/21/2010. Based on Chapter 2 in Advanced Programming Using Visual Basic.NET by Bradley and Millspaugh
Building Multitier Programs with Classes Based on Chapter 2 in Advanced Programming Using Visual Basic.NET by Bradley and Millspaugh The Object-Oriented Oriented (OOP) Development Approach Large production
More informationObject-Oriented Programming (OOP) Fundamental Principles of OOP
Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is
More informationChapter 10 Classes Continued. Fundamentals of Java
Chapter 10 Classes Continued Objectives Know when it is appropriate to include class (static) variables and methods in a class. Understand the role of Java interfaces in a software system and define an
More informationCS-202 Introduction to Object Oriented Programming
CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction
More informationObject Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance
CS257 Computer Science I Kevin Sahr, PhD Lecture 10: Inheritance 1 Object Oriented Features For a programming language to be called object oriented it should support the following features: 1. objects:
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationJAVA MOCK TEST JAVA MOCK TEST II
http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your
More informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationInheritance & Polymorphism Recap. Inheritance & Polymorphism 1
Inheritance & Polymorphism Recap Inheritance & Polymorphism 1 Introduction! Besides composition, another form of reuse is inheritance.! With inheritance, an object can inherit behavior from another object,
More informationJava Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding
Java Class Design Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding eugeny.berkunsky@gmail.com http://www.berkut.mk.ua Objectives Implement encapsulation Implement inheritance
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 : Classes & Objects Lecture Contents What is a class? Class definition: Data Methods Constructors Properties (set/get) objects
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract
More informationInheritance, Polymorphism, and Interfaces
Inheritance, Polymorphism, and Interfaces Chapter 8 Inheritance Basics (ch.8 idea) Inheritance allows programmer to define a general superclass with certain properties (methods, fields/member variables)
More informationObject Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia
Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract
More informationCS6301 PROGRAMMING AND DATA STRUCTURES II QUESTION BANK UNIT-I 2-marks ) Give some characteristics of procedure-oriented language. Emphasis is on doing things (algorithms). Larger programs are divided
More informationChapter 15: Object Oriented Programming
Chapter 15: Object Oriented Programming Think Java: How to Think Like a Computer Scientist 5.1.2 by Allen B. Downey How do Software Developers use OOP? Defining classes to create objects UML diagrams to
More informationProgramming in Java, 2e Sachin Malhotra Saurabh Choudhary
Programming in Java, 2e Sachin Malhotra Saurabh Choudhary Chapter 5 Inheritance Objectives Know the difference between Inheritance and aggregation Understand how inheritance is done in Java Learn polymorphism
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes
More informationSubclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented
Table of Contents L01 - Introduction L02 - Strings Some Examples Reserved Characters Operations Immutability Equality Wrappers and Primitives Boxing/Unboxing Boxing Unboxing Formatting L03 - Input and
More informationChapter 12 Object-Oriented Programming. Starting Out with Games & Graphics in C++ Tony Gaddis
Chapter 12 Object-Oriented Programming Starting Out with Games & Graphics in C++ Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved. 12.1 Procedural and Object-Oriented
More informationINHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U
C A N A D I A N I N T E R N A T I O N A L S C H O O L O F H O N G K O N G INHERITANCE & POLYMORPHISM P2 LESSON 12 P2 LESSON 12.1 INTRODUCTION inheritance: OOP allows a programmer to define new classes
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 : Classes & Objects Lecture Contents What is a class? Class definition: Data Methods Constructors Properties (set/get) objects
More informationC++ & Object Oriented Programming Concepts The procedural programming is the standard approach used in many traditional computer languages such as BASIC, C, FORTRAN and PASCAL. The procedural programming
More informationOOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.
OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.
More informationLecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 : Classes & Objects Lecture Contents What is a class? Class definition: Data Methods Constructors Properties (set/get) objects
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 (a): Classes & Objects Lecture Contents 2 What is a class? Class definition: Data Methods Constructors objects Static members
More informationCOMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed
1 1 COMP200 INHERITANCE OOP using Java, from slides by Shayan Javed 2 Inheritance Derive new classes (subclass) from existing ones (superclass). Only the Object class (java.lang) has no superclass Every
More informationObjects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes
Based on Introduction to Java Programming, Y. Daniel Liang, Brief Version, 10/E 1 Creating Classes and Objects Classes give us a way of defining custom data types and associating data with operations on
More informationObject-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)
Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci) Sung Hee Park Department of Mathematics and Computer Science Virginia State University September 18, 2012 The Object-Oriented Paradigm
More informationAdvanced Programming Using Visual Basic 2008
Building Multitier Programs with Classes Advanced Programming Using Visual Basic 2008 The OOP Development Approach OOP = Object Oriented Programming Large production projects are created by teams Each
More informationInheritance (IS A Relationship)
Inheritance (IS A Relationship) We've talked about the basic idea of inheritance before, but we haven't yet seen how to implement it. Inheritance encapsulates the IS A Relationship. A String IS A Object.
More informationObject Oriented Programming. Java-Lecture 11 Polymorphism
Object Oriented Programming Java-Lecture 11 Polymorphism Abstract Classes and Methods There will be a situation where you want to develop a design of a class which is common to many classes. Abstract class
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationObjective-C: An Introduction (pt 1) Tennessee Valley Apple Developers Saturday CodeJam July 24, 2010 August 7, 2010
Objective-C: An Introduction (pt 1) Tennessee Valley Apple Developers Saturday CodeJam July 24, 2010 August 7, 2010 What is Objective-C? Objective-C is an object-oriented programming language that adds
More informationProgramming Exercise 14: Inheritance and Polymorphism
Programming Exercise 14: Inheritance and Polymorphism Purpose: Gain experience in extending a base class and overriding some of its methods. Background readings from textbook: Liang, Sections 11.1-11.5.
More informationLogistics. Final Exam on Friday at 3pm in CHEM 102
Java Review Logistics Final Exam on Friday at 3pm in CHEM 102 What is a class? A class is primarily a description of objects, or instances, of that class A class contains one or more constructors to create
More informationInheritance. Benefits of Java s Inheritance. 1. Reusability of code 2. Code Sharing 3. Consistency in using an interface. Classes
Inheritance Inheritance is the mechanism of deriving new class from old one, old class is knows as superclass and new class is known as subclass. The subclass inherits all of its instances variables and
More informationAppendix A ACE exam objectives map
A 1 Appendix A ACE exam objectives map This appendix provides the following : A ACE exam objectives for Flash CS6 with references to corresponding coverage in ILT Series courseware. A 2 Flash CS6 ACE Edition
More informationChapter 1: Object-Oriented Programming Using C++
Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms
More informationOverview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017
Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More informationQUESTIONS FOR AVERAGE BLOOMERS
MANTHLY TEST JULY 2017 QUESTIONS FOR AVERAGE BLOOMERS 1. How many types of polymorphism? Ans- 1.Static Polymorphism (compile time polymorphism/ Method overloading) 2.Dynamic Polymorphism (run time polymorphism/
More informationObject-Oriented Programming Concepts
Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are
More informationOverview of the lecture. Some key issues in programming Java programming. CMPT Data and Program Abstraction. Some of the key programming issues
Overview of the lecture CMPT 201 - Data and Program Abstraction Instructor: Snezana Mitrovic-Minic Some key issues in programming Java programming equality of objects inheritance Is-a and has-a relationship
More informationComputer Science 4U Unit 1. Programming Concepts and Skills Modular Design
Computer Science 4U Unit 1 Programming Concepts and Skills Modular Design Modular Design Reusable Code Object-oriented programming (OOP) is a programming style that represents the concept of "objects"
More informationCS11 Introduction to C++ Fall Lecture 7
CS11 Introduction to C++ Fall 2012-2013 Lecture 7 Computer Strategy Game n Want to write a turn-based strategy game for the computer n Need different kinds of units for the game Different capabilities,
More informationObject Oriented Programming
Object Oriented Programming Ray John Pamillo 1/27/2016 1 Nokia Solutions and Networks 2014 Outline: Brief History of OOP Why use OOP? OOP vs Procedural Programming What is OOP? Objects and Classes 4 Pillars
More informationOBJECT ORİENTATİON ENCAPSULATİON
OBJECT ORİENTATİON Software development can be seen as a modeling activity. The first step in the software development is the modeling of the problem we are trying to solve and building the conceptual
More informationObject Oriented Programming: Based on slides from Skrien Chapter 2
Object Oriented Programming: A Review Based on slides from Skrien Chapter 2 Object-Oriented Programming (OOP) Solution expressed as a set of communicating objects An object encapsulates the behavior and
More informationExample: Count of Points
Example: Count of Points 1 public class Point { 2... 3 private static int numofpoints = 0; 4 5 public Point() { 6 numofpoints++; 7 } 8 9 public Point(int x, int y) { 10 this(); // calling Line 5 11 this.x
More informationLecture 10 OOP and VB.Net
Lecture 10 OOP and VB.Net Pillars of OOP Objects and Classes Encapsulation Inheritance Polymorphism Abstraction Classes A class is a template for an object. An object will have attributes and properties.
More informationChapter 12. OOP: Creating Object-Oriented Programs The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill
Chapter 12 OOP: Creating Object-Oriented Programs McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter Objectives - 1 Use object-oriented terminology correctly Create a two-tier
More informationPublic Class ClassName (naming: CPoint)
Lecture 6 Object Orientation Class Implementation Concepts: Encapsulation Inheritance Polymorphism Template/Syntax: Public Class ClassName (naming: CPoint) End Class Elements of the class: Data 1. Internal
More informationMaking New instances of Classes
Making New instances of Classes NOTE: revised from previous version of Lecture04 New Operator Classes are user defined datatypes in OOP languages How do we make instances of these new datatypes? Using
More informationSoftware Paradigms (Lesson 3) Object-Oriented Paradigm (2)
Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Table of Contents 1 Reusing Classes... 2 1.1 Composition... 2 1.2 Inheritance... 4 1.2.1 Extending Classes... 5 1.2.2 Method Overriding... 7 1.2.3
More informationPaytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value
Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object
More informationCPS 506 Comparative Programming Languages. Programming Language
CPS 506 Comparative Programming Languages Object-Oriented Oriented Programming Language Paradigm Introduction Topics Object-Oriented Programming Design Issues for Object-Oriented Oriented Languages Support
More informationCS111: PROGRAMMING LANGUAGE II
1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 4(b): Subclasses and Superclasses OOP OOP - Inheritance Inheritance represents the is a relationship between data types (e.g. student/person)
More informationCHAPTER 5 GENERAL OOP CONCEPTS
CHAPTER 5 GENERAL OOP CONCEPTS EVOLUTION OF SOFTWARE A PROGRAMMING LANGUAGE SHOULD SERVE 2 RELATED PURPOSES : 1. It should provide a vehicle for programmer to specify actions to be executed. 2. It should
More informationCOMP 250 Fall inheritance Nov. 17, 2017
Inheritance In our daily lives, we classify the many things around us. The world has objects like dogs and cars and food and we are familiar with talking about these objects as classes Dogs are animals
More informationCH. 2 OBJECT-ORIENTED PROGRAMMING
CH. 2 OBJECT-ORIENTED PROGRAMMING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) OBJECT-ORIENTED
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
More informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 4&5: Inheritance Lecture Contents What is Inheritance? Super-class & sub class The object class Using extends keyword @override keyword
More informationExample: Fibonacci Numbers
Example: Fibonacci Numbers Write a program which determines F n, the (n + 1)-th Fibonacci number. The first 10 Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, and 34. The sequence of Fibonacci numbers
More informationCSSE 220 Day 15. Inheritance. Check out DiscountSubclasses from SVN
CSSE 220 Day 15 Inheritance Check out DiscountSubclasses from SVN Discount Subclasses Work in pairs First look at my solution and understand how it works Then draw a UML diagram of it DiscountSubclasses
More informationStructured Programming
CS 170 Java Programming 1 Objects and Variables A Little More History, Variables and Assignment, Objects, Classes, and Methods Structured Programming Ideas about how programs should be organized Functionally
More informationInheritance (Outsource: )
(Outsource: 9-12 9-14) is a way to form new classes using classes that have already been defined. The new classes, known as derived classes, inherit attributes and behavior of the pre-existing classes,
More informationObject-Oriented Design
Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1 UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration
More informationIT 201: Information Design Techniques. Review Sheet. A few notes from Professor Wagner s IT 286: Foundations of Game Production Course
IT 201: Information Design Techniques Review Sheet Sources: Notes from Professor Sequeira s IT 201 course at NJIT A few notes from Professor Wagner s IT 286: Foundations of Game Production Course Foundation
More informationOops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:
Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Abstraction Encapsulation Inheritance and Polymorphism Object-Oriented
More informationCOURSE 2 DESIGN PATTERNS
COURSE 2 DESIGN PATTERNS CONTENT Fundamental principles of OOP Encapsulation Inheritance Abstractisation Polymorphism [Exception Handling] Fundamental Patterns Inheritance Delegation Interface Abstract
More informationINHERITANCE AND EXTENDING CLASSES
INHERITANCE AND EXTENDING CLASSES Java programmers often take advantage of a feature of object-oriented programming called inheritance, which allows programmers to make one class an extension of another
More informationSTUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes
STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes Java Curriculum for AP Computer Science, Student Lesson A20 1 STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes INTRODUCTION:
More informationObject- Oriented Design with UML and Java Part I: Fundamentals
Object- Oriented Design with UML and Java Part I: Fundamentals University of Colorado 1999-2002 CSCI-4448 - Object-Oriented Programming and Design These notes as free PDF files: http://www.softwarefederation.com/cs4448.html
More informationOBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak
OBJECT ORIENTED PROGRAMMING Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PARADIGM Object 2 Object 1 Data Data Function Function Object 3 Data Function 2 WHAT IS A MODEL? A model is an abstraction
More informationBasics of Inheritance
Basics of Inheritance CS 5010 Program Design Paradigms "Bootcamp" Lesson 11.1 Mitchell Wand, 2012-2015 This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
More informationLecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page:
Lecturer: Sebastian Coope Ashton Building, Room G.18 E-mail: coopes@liverpool.ac.uk COMP 201 web-page: http://www.csc.liv.ac.uk/~coopes/comp201 Lecture 17 Concepts of Object Oriented Design Object-Oriented
More informationUnit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW
Prepared by: Dr. Abdallah Mohamed, AOU-KW 1 1. Introduction 2. Objects and classes 3. Information hiding 4. Constructors 5. Some examples of Java classes 6. Inheritance revisited 7. The class hierarchy
More informationpublic UndergradStudent(String n, String m, String p) { programme = p; super(n, m);
Tutorial 3: Inheritance Part A Topic: Inheritance 1. Consider the following class definition. class Student { private String name; private String matric_no; a. Write the definition of an empty class named
More information1.00 Lecture 13. Inheritance
1.00 Lecture 13 Inheritance Reading for next time: Big Java: sections 10.5-10.6 Inheritance Inheritance allows you to write new classes based on existing (super or base) classes Inherit super class methods
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 4: OO Principles - Polymorphism http://courses.cs.cornell.edu/cs2110/2018su Lecture 3 Recap 2 Good design principles.
More informationOVERRIDING. 7/11/2015 Budditha Hettige 82
OVERRIDING 7/11/2015 (budditha@yahoo.com) 82 What is Overriding Is a language feature Allows a subclass or child class to provide a specific implementation of a method that is already provided by one of
More informationOOAD - OBJECT MODEL. The concepts of objects and classes are intrinsically linked with each other and form the foundation of object oriented paradigm.
OOAD - OBJECT MODEL http://www.tutorialspoint.com/object_oriented_analysis_design/ooad_object_oriented_model.htm Copyright tutorialspoint.com The object model visualizes the elements in a software application
More informationInheritance and Polymorphism
Inheritance and Polymorphism Inheritance (Continued) Polymorphism Polymorphism by inheritance Polymorphism by interfaces Reading for this lecture: L&L 10.1 10.3 1 Interface Hierarchies Inheritance can
More information