Computer Programming 2 Lecture 8: Object Oriented Programming Creating Classes & Objects Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION.

Slides:



Advertisements
Similar presentations
C++ Classes & Data Abstraction
Advertisements

Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
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.
Object-oriented Programming Concepts
ASP.NET Programming with C# and SQL Server First Edition
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
1.11 Introduction to OOP academy.zariba.com 1. Lecture Content 1.What is OOP and why use it? 2.Classes and objects 3.Static classes 4.Properties, fields.
Computer Programming 2 Lecture 2: Advanced Array Data Structure Using Methods Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER.
Inheritance using Java
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 6 Introduction to classes and objects.
Module 7: Essentials of Object-Oriented Programming.
Introduction to Object-oriented programming and software development Lecture 1.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
Module 7: Object-Oriented Programming in Visual Basic .NET
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 1: Course overview.
Computer Programming 2 Lecture 3: Methods in Advanced & Practices Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER EDUCATION.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
1. 2 Object-Oriented Concept Class & Object Object-Oriented Characteristics How does it work? Relationships Between Classes Development Tools Advantage.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 7 Decision Making : selection statements.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Computer Programming 2 Lecture 1: Advanced Array Data Structure Using Methods Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER.
Encapsulation, Inheritance & Polymorphism. OOP Properties Encapsulation ­The process of creating programs so that information within a class is not accessible.
Computer Programming 2 Lecture 5: String Processing Part b: Class StringTokenizer Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
: Maha Sabri Altememe Lecturer : Maha Sabri Altememe Lecture :1 1.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Introduction to Object Oriented Programming (OOP) Object Oriented programming is method of programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
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.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA ‏ Properties of Object Oriented Programming.
Seventh step for Learning C++ Programming CLASS Declaration Public & Private Constructor & Destructor This pointer Inheritance.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Data Structures Lecture 4: Classes in C++ Azhar Maqsood NUST Institute of Information Technology (NIIT)
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Object Oriented Programming
University of Central Florida COP 3330 Object Oriented Programming
Classes and OOP.
Table of Contents Class Objects.
University of Central Florida COP 3330 Object Oriented Programming
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Can perform actions and provide communication
Can perform actions and provide communication
OBJECT ORIENTED PROGRAMMING II LECTURE 8 GEORGE KOUTSOGIANNAKIS
Can perform actions and provide communication
CS2011 Introduction to Programming I Objects and Classes
By Rajanikanth B OOP Concepts By Rajanikanth B
Final and Abstract Classes
CSG2H3 Object Oriented Programming
Presentation transcript:

Computer Programming 2 Lecture 8: Object Oriented Programming Creating Classes & Objects Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY (CST) KHANYOUNIS- PALESTINE

و من يتقِ الله... قال الله تعالى : ( وَإِبْرَاهِيمَ إِذْ قَالَ لِقَوْمِهِ اعْبُدُوا اللَّهَ وَاتَّقُوهُ ذَلِكُمْ خَيْرٌ لَكُمْ إِنْ كُنْتُمْ تَعْلَمُونَ ) ( العنكبوت :16) Mahmoud Rafeek Alfarra 2 Downloaded from شريحـة ثابتـة لعلنا نحسن من خلالها أخلاقنـا و أفعالنا لنفوز يوم الامتحان الحقيقي

Out Lines Mahmoud Rafeek Alfarra Downloaded from Downloaded from 3 What is OOP? why? Main Concepts of OOP Thinking in Objects. Class & Object Access modifiers How To build Classes How To create Objects

What is OOP? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 4 Object oriented programming, or OOP, is one model of programming language. Unlike other examples of computer programming language, object oriented programming focuses on the use of objects instead of actions in order to carry out tasks.

why? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 5 Re-use: he power of object-oriented systems lies in their promise of code reuse which will increase productivity, reduce costs and improve software quality. Modularity: The source code for an object can be written and maintained independently of the source code for other objects. Once created, an object can be easily passed around inside the system.

Main Concepts of OOP Mahmoud Rafeek Alfarra Downloaded from Downloaded from 6 A computer language can be aid to be Object Oriented if it provides support for the following, which are presented by classes & objects: Abstraction Polymorphism Encapsulation Inheritance

Main Concepts of OOP Mahmoud Rafeek Alfarra Downloaded from Downloaded from 7 Encapsulation: The act of placing data and the operations that perform on that data in the same class. The class then becomes the 'capsule' or container for the data and operations.

Main Concepts of OOP Mahmoud Rafeek Alfarra Downloaded from Downloaded from 8 Inheritance: The reuse of base classes (superclasses) to form derived classes (subclasses). Methods and properties defined in the superclass are automatically shared by any subclass. طالب جامعي بكالوريوسدبلوم مدرسي ابتدائيإعداديثانوي

Main Concepts of OOP Mahmoud Rafeek Alfarra Downloaded from Downloaded from 9 Polymorphism: Same interface, different implementation. The ability to substitute one class for another.

Main Concepts of OOP Mahmoud Rafeek Alfarra Downloaded from Downloaded from 10 Different classes may contain the same method names, but the result which is returned by each method will be different as the code behind each method (the implementation) is different in each class.

Main Concepts of OOP Mahmoud Rafeek Alfarra Downloaded from Downloaded from 11 Abstraction: using the methods of classes without care how they are implemented. ؟

Thinking in Objects Mahmoud Rafeek Alfarra Downloaded from Downloaded from 12 Every thing in the world is an object of class which contains attributes behavior

Class & Object Mahmoud Rafeek Alfarra Downloaded from Downloaded from 13 A class is a blueprint, or prototype, that defines the variables (data) and the methods (operations) common to all objects of a certain kind. An instance of a class. A class must be instantiated into an object before it can be used in the software. More than one instance of the same class can be in existence at any one time.

Class & Object Mahmoud Rafeek Alfarra Downloaded from Downloaded from 14

Class & Object Mahmoud Rafeek Alfarra Downloaded from Downloaded from 15

How To build Classes? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 16 Any Thing (Class) Any Thing (Class) Attributes Behavior Each one is a represented as a variable in class Each one is a represented as a variable in class Each one is a represented as a Method in class Each one is a represented as a Method in class

How To build Classes? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 17 Bank Account ID, owner, amount, … Withdraw, deposit, transfer Each one is a represented as a variable in class Each one is a represented as a variable in class Each one is a represented as a Method in class Each one is a represented as a Method in class

How To build Classes? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 18 Access_modifiers class class_name { Access_modifiers class_name() { } Access_modifiers class class_name { Access_modifiers class_name() { } Constructor method Which gives the initial values to the variables Reserved word Name of class, must match The identifier rules As public

Access Modifiers Mahmoud Rafeek Alfarra Downloaded from Downloaded from 19 private: private members are accessible only in the class itself package: package members are accessible in classes in the same package and the class itself protected: protected members are accessible in classes in the same package, in subclasses of the class, and in the class itself public: public members are accessible anywhere the class is accessible

Example: Student Class Mahmoud Rafeek Alfarra Downloaded from Downloaded from 20 Lname string Student_ID string Level int Tel string Gender string Program string Print_info Input: - return: void Print_info Input: - return: void Update_info Input: name or ID Return : void Update_info Input: name or ID Return : void Fname string

Example: Student Class Mahmoud Rafeek Alfarra Downloaded from Downloaded from 21 Instance variableConstructor

Example: Student Class Mahmoud Rafeek Alfarra Downloaded from Downloaded from 22 Method Overloaded Method

How To create Objects? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 23 Class_name object_name = new Class_name (); Class_name object_name = new Class_name ( value1, value2 );

Example: Student Class (cont’) Mahmoud Rafeek Alfarra Downloaded from Downloaded from 24

Next Lecture … Mahmoud Rafeek Alfarra Downloaded from Downloaded from 25 How to store Objects in Array & why?