Object Oriented Programming April 13, 2007. Problem Description “ …Wombats are allowed to have different directions and number of eaten leaves, move,

Slides:



Advertisements
Similar presentations
Object Oriented Programming. Object Oriented Data and operations are grouped together Account Withdraw Deposit Transfer Interface: Set of available operations.
Advertisements

Object Oriented Programming. Problem Description “ …customers are allowed to have different types of bank accounts, deposit money, withdraw money and.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Department of computer science N. Harika. Inheritance Inheritance is a fundamental Object Oriented concept A class can be defined as a "subclass" of another.
Module 2: Object-Oriented Programming
Course Description: Title : Object Oriented Systems
Object Oriented Programming | Website for students | VTU NOTES.
ITEC200 – Week03 Inheritance and Class Hierarchies.
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
Object-Oriented PHP (1)
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
CS 106 Introduction to Computer Science I 11 / 15 / 2006 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 11 / 19 / 2007 Instructor: Michael Eckmann.
ISE 582: Web Technology for Industrial Engineers University of Southern California Department of Industrial and Systems Engineering Lecture 4 JAVA Cup.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object Oriented Programming. Problem Description “ …customers are allowed to have different types of bank accounts, deposit money, withdraw money and.
BACS 287 Basics of Object-Oriented Programming 1.
LECTURE 07 Programming using C# Inheritance
Object-Oriented Programming Concepts
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Module 7: Essentials of Object-Oriented Programming.
CS 106 Introduction to Computer Science I 04 / 13 / 2007 Friday the 13 th Instructor: Michael Eckmann.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
OBJECT AND CLASES: THE BASIC CONCEPTS Pertemuan 8 Matakuliah: Konsep object-oriented Tahun: 2009.
An Object-Oriented Approach to Programming Logic and Design
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
1. 2 Object-Oriented Concept Class & Object Object-Oriented Characteristics How does it work? Relationships Between Classes Development Tools Advantage.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
© S Ramakrishnan, Monash University oops1.ppt 1 Object-Oriented Programming Systems SFT3021 Semester Lecturer: Sita Ramakrishnan
1 Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill Chapter 2: Object Basics Object-Oriented Systems Development Using the Unified Modeling.
Object-Oriented Programming. An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.
Parameters… Classes Cont Mrs. C. Furman October 13, 2008.
1 Inheritance Chapter 9. 2 What You Will Learn Software reusability (Recycling) Inheriting data members and functions from previously defined classes.
Design Model Lecture p6 T120B pavasario sem.
Class Modeling Design Class diagram. Classes The term “class ” refers to a group of objects that share a common attributes and common behaviour (operations).
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
AD Lecture #1 Object Oriented Programming Three Main Principles 1 Inheritance Encapsulation Polymorphism.
(c) University of Washington06-1 CSC 143 Java Inheritance Tidbits.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
ISBN Chapter 12 Support for Object-Oriented Programming.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Objects as a programming concept
Computing with C# and the .NET Framework
Types of Programming Languages
Object Oriented Analysis and Design
OBJECT ORIENTED PROGRAMMING II LECTURE 8 GEORGE KOUTSOGIANNAKIS
Software Design Lecture : 12.
Inheritance Inheritance is a fundamental Object Oriented concept
Object Oriented Programming
Workshop for Programming And Systems Management Teachers
By Rajanikanth B OOP Concepts By Rajanikanth B
Object Oriented Analysis and Design
Lecture 10 Concepts of Programming Languages
Presentation transcript:

Object Oriented Programming April 13, 2007

Problem Description “ …Wombats are allowed to have different directions and number of eaten leaves, move, turn, find leaves and eat leaves”

Mapping the world to software Objects in the problem domain are mapped to objects in software

Object Oriented Data and operations are grouped together WombatWorld

Data Encapsulation class Wombat { private int direction; private int leavesEaten; public Wombat() {… } public move() { … }

Advantages of Encapsulation Protection Consistency Allows change

Objects and Classes Classes reflect concepts, objects reflect instances that embody those concepts. Dana Jane Emily Sarah woman class object Not Fred

Objects and Classes cont’d Class BankAccount Balance InterestYTD Owner Account_number Balance:500 InterestYTD: 10 Owner: Mark Account_number: Balance 10,000 InterestYTD: 25 Owner: Martha Account_number: Operations MakeDesposit Transfer WithDraw GetBalance

Objects as instances of Classes The world conceptually consists of objects Many objects can be said to be of the same type or class My bank account, your bank account, Bill Gates’ bank account … We call the object type a class

Instantiation An Object is instantiated from a Class BankAccount myAccount; myAccount = new BankAccount();

Objects and Classes Class Visible in source code The code is not duplicated Object Own copy of data Active in running program Occupies memory Has the set of operations given in the class

Classification Mammal RodentPrimateCat Reptile Animal SquirrelRabbitMouse

Classification WombatRock Actor

Inheritance A class which is a subtype of a more general class is said to be inherited from it. The sub-class inherits the base class’ data members and member functions

Inheritance cont’d A sub-class has all data members of its base-class plus its own A sub-class has all member functions of its base class (with changes) plus its own Look at the wombatWorld -- what Actor functions or methods are used in the Wombat class?

Polymorphism Polymorphism comes from the Greek language and means ”many shapes”. Overloading One interface with multiple implementations or methods. Each method must have a distinct signature. Overriding When a subclass has a method with the same signature (number, type and order of parameters) as a method in one of its superclasses.

Overloading Example One interface with multiple implementations or methods. Each method must have a distinct signature. Example: fill() fill(gray) fill(gray, alpha) fill(value1, value2, value3) fill(value1, value2, value3, alpha) fill(color) fill(color, alpha) fill(hex) fill(hex, alpha)

Polymorphism Parameters gray int or float: number specifying value between white and black alpha int or float: opacity of the fill value1 int or float: red or hue value value2 int or float: green or saturation value value3 int or float: blue or brightness value color color: any value of the color datatype hex int: color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00)

Overriding : Example Look at the wombat class and the actor class: each has an act() method. A wombat instance of the Wombat class will use the wombat act(). (Check out the Actor class’s act() method. What does it do?)

What is a good class ? A class abstracts objects A class should be non-trivial in the context of the program (has data structures and operations different from other classes)

Class Design Use “is a” or “has a” to determine whether something should be a subclass or be a data item. Ex: A dog has a name. Not: A dog is a name. A dog is a mammal. Not: A dog has a mammal. (unless its in predator-mode which isn’t a step in oo design).

Summary What is Object Oriented Programming? Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of one or more hierarchy of classes united via inheritance relationships

Importance of Documenation The Greeps assignment will require you to read the documentation. As practice for the Greeps assignment, in class today create the car game found at /c2/Car_Game_Tutorial.zip /c2/Car_Game_Tutorial.zip The line image isn’t included -- use whatever you want! What method has replaced stopSimulation() in Greenfoot? What method can you use to play a sound?

Things to Note getX() and getY() are methods of the base class Actor but are used in the Car class. World class methods used in Car class include removeObject(), getHeight() and addObject(). They are called by getWorld().method-call Example: getWorld().removeObject(this)