Lesson Objectives Aims Key Words:

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
General OO Concepts Objectives For Today: Discuss the benefits of OO Programming Inheritance and Aggregation Abstract Classes Encapsulation Introduce Visual.
More about classes and objects Classes in Visual Basic.NET.
Object-Oriented PHP (1)
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Object Oriented Software Development
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
An Object-Oriented Approach to Programming Logic and Design
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Programming using C# for Teachers Introduction to Objects Reference Types Functions of Classes Attributes and Types to a class LECTURE 2.
10-Nov-15 Java Object Oriented Programming What is it?
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Inheritance Objectives: Creating new classes from existing classes The protected modifier Creating class hierarchies Abstract classes Indirect visibility.
Classes, Interfaces and Packages
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
CMSC201 Computer Science I for Majors Lecture 25 – Classes
Introduction to Object-oriented Programming
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
Phil Tayco Slide version 1.0 Created Sep 10, 2017
Chapter - 4 OOP with C# S. Nandagopalan.
OOP Course - Virtual Trip
Sachin Malhotra Saurabh Choudhary
Programming Logic and Design Seventh Edition
Classes and OOP.
Andy Wang Object Oriented Programming in C++ COP 3330
Programming in Java Sachin Malhotra, Chairperson, PGDM-IT, IMS Ghaziabad Saurabh Chaudhary, Dean, Academics, IMS Ghaziabad.
The Object-Oriented Thought Process Chapter 1
Object Oriented Concepts -I
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Abstract Classes and Inheritence Operator over-loading
Object Oriented Concepts
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Chapter 7 Classes & Objects.
Object-oriented programming
Class Inheritance (Cont.)
Inheritance Basics Programming with Inheritance
OOP Paradigms There are four main aspects of Object-Orientated Programming Inheritance Polymorphism Abstraction Encapsulation We’ve seen Encapsulation.
Week 6 Object-Oriented Programming (2): Polymorphism
Chapter 9 Classes & Objects.
Computer Programming with JAVA
CS2011 Introduction to Programming I Objects and Classes
Chapter 7 Classes & Objects.
Defining Classes and Methods
Object-Oriented Programming in PHP
Applying OO Concepts Using Java
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
Chapter 5: Classes and Objects in Depth
UNIT I OBJECT ORIENTED PROGRAMMING FUNDAMENTALS
CISC/CMPE320 - Prof. McLeod
COP 3330 Object-oriented Programming in C++
Introduction to Data Structure
Lesson Objectives Aims Key Words
Object-Oriented Programming
Chapter 7 Classes & Objects.
Defining Classes and Methods
Chapter 5: Classes and Objects in Depth
Review of Previous Lesson
Review of Previous Lesson
Object-Oriented PHP (1)
Final and Abstract Classes
Chapter 9 Introduction To Classes
Object Oriented Programming(OOP)
C++ Object Oriented 1.
Presentation transcript:

Lesson Objectives Aims Key Words: To be able to understand the Object Oriented paradigm To be able to understand key OO terms Key Words: Class, Method, Constructor, Inheritance, Polymorphism

Object Orientation A method of programming where real world or abstract concepts are represented as “Objects” An object can be anything:

Exam board definition Class: A template Which defines methods and attributes Of/used to make objects

Objects An object is defined in a “class” A class is: A definition of the object A constructor used to make new versions of the object A set of methods (things it can do) An object should be seen as a template – you never use the class itself, you create copies of it by making NEW objects to use in your code.

A Class A class will contain: The name of the class A constructor (code that is automatically called and run when a new instance of an object is created) Attributes (Data stored in variables) Methods (things the class can do, including getting and setting data)

Exam board definition Attribute: A variable or piece of data in a class

When designing a class, you must decide: What data does the object need to store What data does the object need when it is created What does it need to be capable of doing? Lets do an example.

Task We want to make a simple database to store details of cars we sell Each car has: A make A model Purchase Price Mileage It would be nice if we could do/find out the following: Add or retrieve the list price of the car Add or retrieve the age of the car Calculate the market value of the car based on age, list price and depreciation Display all car details

We are going to create a Car class. Task We are going to create a Car class. Write out a class definition in a table: Object Name Properties (values it stores) Methods (things you want it to be able to do)

Example Object Name Car Properties (values it stores) Make as String Model as String Mileage as Integer Age as integer ListPrice as double PurchasePrice as double Methods (things you want it to be able to do) GetAllDetails() SetListPrice(Price as double) GetlListPrice() CalculateDepreciation() getAge() Setage(Year as integer)

How a class looks Lets have a look at a outline class declaration together Then you can try and fill in your own We will then work together to write the code …and some test code to try it out

Inheritance If an object exists, but doesn’t do exactly what you need… …or isn’t specific enough for your needs then… …take the code and bolt on your own bits

Inheritance is a class which takes ALL of the functionality of an existing class All of the methods, data storage etc And allows you to build on it, change methods etc. This is done in a new class of its own so as not to damage or alter the “base” class

Inheritance terms The base class is called the “parent” class Any inheriting classes are called “Child” classes Time for an example

Example Parent class Person Person has attributes Fname, Sname and age Methods – Getname(), setname(), GetFullname()

Example Child Class Employee Has all attributes and methods of Person Adds attributes – Position, salary Adds methods – getposition(), setSalary() etc

Exam board definition Inheritance: A class which takes on the methods And attributes Of a parent class. An inheriting class may override some of the methods/attributes (polymorphism) And may have additional methods and attributes of its own

Polymorphism Functions or methods that have the same name But can be called in different ways Concatenate(23, 154) Concatenate(“Chunder “, “Jacket”)

Why OO? We create abstract code blocks that can be re-used Existing classes can be modified through inheritance to create classes for our own needs, but with minimal work Powerful method of storing and manipulating program code Automatically breaks down development in to manageable chunks

Continued Encapsulation allows all data to be protected by code you write For example, you cannot change a value without calling a method. This is “strong abstraction” – you are kept away from the raw data and must pass it through a method to access it

Review/Success Criteria You should know: What an object is What the terms Class, Method, Property, inheritance and polymorphism mean How to create a basic class How to define a basic class