SlideShare a Scribd company logo
PROPAGATING IN .NET
By Muhammad Naveed
MCS University of AJK, DIT
Instructor Moon Creations School of IT
1
OOP
 Function +data
 In modular programming functions and data is
separated.
 i.e.
student
{
Student info
}
Courses
{
Course info.
}
210/13/2012Muhammad Naveed
OOP
 So every thing is separated data and
operations .
 Class is an instance of an object, which
defines state and behavior of an object.
 Object can interacts with each other by
message passing.
310/13/2012Muhammad Naveed
Class
 To house (among other things)
 In class we provide one or more methods that are
designed to perform the class tasks.
 For example: a bank account class might contain one or
more methods to deposit money, withdraw money and
balance inquiry.
 Collection of similar objects, with different names
 Class in an passive entity.
 Class in template or blue print
 Class is module or sketch.
 Class has data members and functions on which class
performs its functionalities.
 Data and functions are combined
410/13/2012Muhammad Naveed
Object
 We have to build a object of class to actually
gets its fruits. C# called OOP
 Object is an active entity.
 Object has properties or methods/
attitudes/ functions/operations/data
members/fields
 So objects has state and behaviors
 Students is an object.
 Employee is an object
510/13/2012Muhammad Naveed
Methods
 Performing a task in an application requires
a method. The method describes the
mechanism that actually perform its task.
The method hides from its user the complex
tasks. Just as the accelerator pedal of a car
hides from the driver the complex
mechanism of making the car go faster.
610/13/2012Muhammad Naveed
Attributes
 Every objects muse have some attributes or properties
like color, size, shape etc.
 Attributes are specified by the class’ instance variables
 Properties Get assessors and set assessors
 Attributes are not necessarily accessible directly. The car
manufacturer does not want drivers to take apart the
car’s engine to observe the amount of gas in its tank.
 Instead the driver can check the fuel gauge on the
dashboard.
 So in c# we use get accessors for reading and set
accessors for storing values.
710/13/2012Muhammad Naveed
STATIC Methods
 Sometimes a method performs a task that
does not depend on the contents of any
object. So can be called with out creating its
object this is called static method.
 Syntax
 ClassName. MethodName(arguments)
 Always called with class name and method
name
810/13/2012Muhammad Naveed
910/13/2012Muhammad Naveed
Constructor
 Constructor is used to initialize the object of
the class.
 Behaves like Function
 Constructor is just like function, but it is a
special type of function.
 Same name like class
 Class student
 Public student( )
 Defaults constructor has no argument or
parameters
1010/13/2012Muhammad Naveed
Properties Function
 These are get and set functions
 Not a fully function but behaves like
function.
 Used to get and set values of private data
members of a class
1110/13/2012Muhammad Naveed
 int n;
 Console.WriteLine("Enter a number");
 n = Convert.ToInt32(Console.ReadLine());
 if (n > 0)
 {
 Console.WriteLine("The Number is +ve");
 }
 else
 {
 Console.WriteLine("The number is -ve");
 }
 Console.Read();
 int n;
 n = 1;
 while (n <= 5)
 {
 Console.WriteLine("Kashmir");
 n++;
 }
 Console.Read();
1210/13/2012Muhammad Naveed
Major Concepts
 OOP
 Classes
 Objects
 Methods
 Properties
 Instance Variables
1310/13/2012Muhammad Naveed
1410/13/2012Muhammad Naveed
1510/13/2012Muhammad Naveed
Features of OOP
 Inheritance
 Polymorphism
 Encapsulation
 Abstraction
1610/13/2012Muhammad Naveed
STRUCTURED VS. OO PROGRAMMING
17
STRUCTURED PROGRAMMING:
10/13/2012Muhammad Naveed
Structured Programming
 Using function
 Function & program is divided into modules
 Every module has its own data and function
which can be called by other modules.
1810/13/2012Muhammad Naveed
OBJECT ORIENTED PROGRAMMING
1910/13/2012Muhammad Naveed
OBJECT ORIENTED PROGRAMMING
Objects have both data and methods
Objects of the same class have the same data elements
and methods
Objects send and receive messages to invoke actions
Key idea in object-oriented:
The real world can be accurately described as a collection of
objects that interact.
2010/13/2012Muhammad Naveed
Basic terminology
object
- usually a person, place or thing (a noun)
method
- an action performed by an object (a verb)
attribute
- description of objects in a class
class
- a category of similar objects (such as automobiles)
- does not hold any values of the object’s attributes
2110/13/2012Muhammad Naveed
Example for attributes and methods
Attributes:
 manufacturer’s name
 model name
 year made
 color
 number of doors
 size of engine
 etc.
Methods:
 Define data items
(specify
manufacturer’s name,
model, year, etc.)
 Change a data item
(color, engine, etc.)
 Display data items
 Calculate cost
 etc.
2210/13/2012Muhammad Naveed
WHY OOP?
Save development time (and cost) by reusing code
once an object class is created it can be used in other
applications
Easier debugging
classes can be tested independently
reused objects have already been tested
2310/13/2012Muhammad Naveed
DESIGN PRINCIPLES OF OOP
Four main design principles of Object-Oriented
Programming(OOP):
Encapsulation(information hiding)
Abstraction(hide unnecessary details )
Polymorphism(same thing behave differently)
Inheritance(derived class inherit from base class)
2410/13/2012Muhammad Naveed
ENCAPSULATION
Also known as data hiding
Only object’s methods can modify information in the
object.
Data and Function Encapsulated within a single
package ‘class’.
Analogy:
ATM machine can only update accounts of one
person or object only.
2510/13/2012Muhammad Naveed
Abstraction
 Focus only on the important facts about the
problem at hand
 to design, produce, and describe so that it can be
easily used without knowing the details of how it
works.
Analogy:
 When you drive a car, you don’t have to know how
the gasoline and air are mixed and ignited.
 Instead you only have to know how to use the
controls.
 Draw map
2610/13/2012Muhammad Naveed
POLYMORPHISM
the same word or phrase can mean different things
in different contexts
Analogy:
In English, bank can mean side of a river or a place
to put money
move -
2710/13/2012Muhammad Naveed
Function Overloading
 The operation of one function depends on the
argument passed to it.
 Example: Fly(), Fly(low), Fly(150)
2810/13/2012Muhammad Naveed
INHERITANCE
Inheritance—a way of organizing classes
Term comes from inheritance of traits like eye color,
hair color, and so on.
Classes with properties in common can be grouped so
that their common properties are only defined once.
Superclass – inherit its attributes & methods to the
subclass(es).
Subclass – can inherit all its superclass attributes &
methods besides having its own unique attributes &
methods.
2910/13/2012Muhammad Naveed
AN INHERITANCE HIERARCHY
30
Vehicle
Automobile Motorcycle Bus
Sedan Sports Car School BusLuxury Bus
What properties does each vehicle inherit from the types
of vehicles above it in the diagram?
Superclass
Subclasses
10/13/2012Muhammad Naveed
OBJECT-ORIENTED PROGRAMMING
LANGUAGES
 Pure OO Languages
C#, Smalltalk, Eiffel, Actor, Java
 Hybrid OO Languages
C++, Objective-C, Object-Pascal
3110/13/2012Muhammad Naveed
Review: Introduction to Object
Orientation
 What are the four basic principles of object
orientation? Provide a brief description of
each.
 What is an Object and what is a Class? What is
the difference between them?
 What is an Attribute?
 What is an Operation?
 What is inheritance?
 What is polymorphism?
 Describe the strengths of object orientation.
3210/13/2012Muhammad Naveed
Review: Introduction to Object
Orientation
 State 2 differences between functional
programming and OOP.
 What are the four basic principles of object
orientation? Provide a brief description of
each.
 What is an Object and what is a Class? What is
the difference between them?
 What is an Attribute?
 What is an Operation?
 Describe the strengths of object orientation.
3310/13/2012Muhammad Naveed
Polymorphism
 Compile time polymorphism(Overloading)
 Run time Polymorphism( Overriding )
3410/13/2012Muhammad Naveed
Compile Time
Polymorphism(Overloading)
 Can be Achieved by
 Function Overloading
 Operator Overloading
 Constructor Overloading
3510/13/2012Muhammad Naveed
Compile Time
Polymorphism(Overloading)
 Function Overloading
 It means same thing behaves differently
 Public void get()
 Public void get(int r)
 Public void get(int r, string n)
 Public void get(int r, string n, string rem….)
 So same function behaves differently by increasing
number of parameters or arguments i.e. no argument, one
argument or two or may be three or even more.
 So this is how we can achieve Compile time polymorphism
that is overloading
 Also function type or signature can be changed, so that
it can be define with same name but with different
parameters.
3610/13/2012Muhammad Naveed
Example
3710/13/2012Muhammad Naveed
Compile Time
Polymorphism(Overloading)
 Operator Overloading
 Some operators can also behaves differently
called operator overloading (polymorphism).
Operator can be redefined to achieve the
operator overloading.
3810/13/2012Muhammad Naveed
Operator Overloading
3910/13/2012Muhammad Naveed
Example 2
4010/13/2012Muhammad Naveed
4110/13/2012Muhammad Naveed
4210/13/2012Muhammad Naveed
4310/13/2012Muhammad Naveed
4410/13/2012Muhammad Naveed
Compile Time
Polymorphism(Overloading)
 3. Constructor Overloading
4510/13/2012Muhammad Naveed
4610/13/2012Muhammad Naveed
4710/13/2012Muhammad Naveed
4810/13/2012Muhammad Naveed
4910/13/2012Muhammad Naveed
Lecture
 Intro to GUI using C#
 Windows Applications
 Windows Forms
5010/13/2012Muhammad Naveed
Run Time Polymorphism
(Overriding)
 We have learned about compile time
polymorphism which is overloading.
 Function Overloading
 Public void get(int n)
 Operator Overloading
 Public static room operaotr +(room rm1, room
rm2)
 Constructor Overloading
 Public student(string n,…)
5110/13/2012Muhammad Naveed
Run Time Polymorphism
(Overriding)
 Now in this case we have to change the
signature or nos of parameters to get
function overloading. Which we have done.
 But in some situations, we have to use same
function with the same name signature this
is called overriding. this situation can be
used in parent class relationship i.e.
 Where we have to use virtual function, That
needs to be redefined again and again. It
gives the 1st definition of that function,
5210/13/2012Muhammad Naveed
Run Time Polymorphism
(Overriding)
 Because same name with same signature
needs to be redefined using virtual keyword
in the parent class.
 And to access this in the child class we have
to use override keyword.
5310/13/2012Muhammad Naveed
Example
5410/13/2012Muhammad Naveed
OOP: Inheritance
 Inheritance a form of software reuse.
 Lets you save much of your time in software
development.
 The existing class from which a new class
inherits is called base class, and the new
class is called derived class
 Each derived class can become the base
class for next extended class
 And new data members can be added.
10/13/2012Muhammad Naveed 55
OOP: Inheritance
Base Class Derived Class
Student Graduate Student, Undergradulate
Shape Oval, Rectangle, elpse
Loan CarLoan, HomeLoan
BankAccount Currant, Saving etc
10/13/2012Muhammad Naveed 56
OOP: Inheritance
10/13/2012Muhammad Naveed 57
Community
Member
Employee
Faculty
Admin Teacher
Staff
Student Alumnus
OOP: Inheritance
 Protected Members
 Commonly we used Public and Private
 Public data members are accessible
whenever the application has a reference to
an object of that class or one of its derived
class.
 Private data members are inherited from its
derived class, but are not accessible by
derived class and methods.
10/13/2012Muhammad Naveed 58
OOP: Inheritance
 Protected :
 Provides an intermediate level of
accessibility b/w public and private. These
can be accessible by members of that base
class and by members of its derived class
10/13/2012Muhammad Naveed 59
Relationship b/w base
classes and derived classes
10/13/2012Muhammad Naveed 60
10/13/2012Muhammad Naveed 61
10/13/2012Muhammad Naveed 62
10/13/2012Muhammad Naveed 63
10/13/2012Muhammad Naveed 64
10/13/2012Muhammad Naveed 65
 The above examples show polymorphism,
inheritance, constructor overloading and
function overloading, private and public
data members w.r.t access.
 Reference Book
 C# 2010 for programmers.
 Chapter 11, OOP Programming: inheritance
page:320 etc
10/13/2012Muhammad Naveed 66
summery
Abstract Class and Methods
 We can not create object of the Abstract
Class.
 The purpose of the abstract class is
primarily to provide and appropriate base
class from which other classes can inherit
and thus share a common design.
 Public abstract void show()//abstract
method
10/13/2012Muhammad Naveed 67
Case Study
 Scenario
10/13/2012Muhammad Naveed 68
Payroll System Using
Polymorphism
 A company pay in employees on a weekly basis.
 The employees are of four types.
 Salaried Employees: are paid a fixed weekly salary
regardless of the number of hours worked.
 Hourly Employees: are paid by hour and receive
“time and a half” overtime pay for their sales.
 Salaried commission employees: are paid a
percentage of their sales.
 For the current pay period the company has decides
to reward salaried commission employees by adding
10% to their base salaries.
 Company demands a C# application.
10/13/2012Muhammad Naveed 69
Solution
 We use abstract class as employee for
general concept.
 The other class that extends from employee
abstract class are: SalariedEmployee,
CommissionEmployee and
HourlyEmployee.
 ClassBasePlusCommissioEmployee Which
extends from CommissionEmployee.
 UML
10/13/2012Muhammad Naveed 70
Employee
SalariedEmployee CommissionEmployee
BasePlusCommissionEmployee
HourlyEmployee
10/13/2012Muhammad Naveed 71
Cases
Classes Earnigns ToString
Employee Abstract The abstract class for all
other classes as a
foundation first
name,last name, social
security number SSN
Salaried Employee weeklySalary Salaried
employee:employee
Weekly salary:
Hourly Employee If hours<=40
Wage=hours
Ifhours>40
40*wage+(hours-
40)+wage=1.5
Hourlty
employee:employee
Houtly wage :wage
Hours work:hours
Comission Employee commissionRate*grossS
ales
Inherit from employee
Gross sale:grassSales
Comission
rate:comissionRate
BasePlusComissionEmpl
oyee
comissionRate*grossSal
es+baseSalry
Base Salaried comsiion
employee:10/13/2012Muhammad Naveed 72
Solution Book page no344
10/13/2012Muhammad Naveed 73
Exception Handling
 Try
 {
 Throuth exception()
 }
 Catch
 {
 Catch exception()
 }
 Finally
 {
 Show final()
 }
10/13/2012Muhammad Naveed 74
Overview
10/13/2012Muhammad Naveed 75
GUI : Windows Forms
10/13/2012Muhammad Naveed 76
Events And Handling them
10/13/2012Muhammad Naveed 77

More Related Content

What's hot

Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Simplilearn
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
Lovely Professional University
 
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and Interface
Haris Bin Zahid
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
talha ijaz
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
Sujit Majety
 
General OOP Concepts
General OOP ConceptsGeneral OOP Concepts
General OOP Concepts
Praveen M Jigajinni
 
Oops presentation java
Oops presentation javaOops presentation java
Oops presentation java
JayasankarPR2
 
Object Oriented Concepts in Real Projects
Object Oriented Concepts in Real ProjectsObject Oriented Concepts in Real Projects
Object Oriented Concepts in Real Projects
EPAM
 
What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | Edureka
Edureka!
 
Abstraction and Encapsulation
Abstraction and EncapsulationAbstraction and Encapsulation
Abstraction and Encapsulation
Haris Bin Zahid
 
Oop in kotlin
Oop in kotlinOop in kotlin
Concepts of oops
Concepts of oopsConcepts of oops
Concepts of oops
Sourabrata Mukherjee
 
Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
Pritom Chaki
 
Chapter 9 Interface
Chapter 9 InterfaceChapter 9 Interface
Chapter 9 Interface
OUM SAOKOSAL
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
deonpmeyer
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
Shreyans Pathak
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
Md. Tanvir Hossain
 

What's hot (20)

Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
 
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and Interface
 
OOPS Characteristics
OOPS CharacteristicsOOPS Characteristics
OOPS Characteristics
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
General OOP Concepts
General OOP ConceptsGeneral OOP Concepts
General OOP Concepts
 
Oops presentation java
Oops presentation javaOops presentation java
Oops presentation java
 
Object Oriented Concepts in Real Projects
Object Oriented Concepts in Real ProjectsObject Oriented Concepts in Real Projects
Object Oriented Concepts in Real Projects
 
What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | Edureka
 
Abstraction and Encapsulation
Abstraction and EncapsulationAbstraction and Encapsulation
Abstraction and Encapsulation
 
Oop in kotlin
Oop in kotlinOop in kotlin
Oop in kotlin
 
Concepts of oops
Concepts of oopsConcepts of oops
Concepts of oops
 
Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
 
General oops concepts
General oops conceptsGeneral oops concepts
General oops concepts
 
Chapter 9 Interface
Chapter 9 InterfaceChapter 9 Interface
Chapter 9 Interface
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 

Viewers also liked

Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)
OUM SAOKOSAL
 
Basics of oops concept
Basics of oops conceptBasics of oops concept
Basics of oops concept
DINESH KUMAR ARIVARASAN
 
OOP Basics
OOP BasicsOOP Basics
OOP Basics
CIB Egypt
 
Technical Excellence - OOP Munich 2015
Technical Excellence - OOP Munich 2015Technical Excellence - OOP Munich 2015
Technical Excellence - OOP Munich 2015
James Grenning
 
Delegates in C#
Delegates in C#Delegates in C#
Delegates in C#
SNJ Chaudhary
 
Flow chart and pseudo code
Flow chart and pseudo code Flow chart and pseudo code
Flow chart and pseudo code
Niva tharan
 
Fluent interface in c#
Fluent interface in c#Fluent interface in c#
Fluent interface in c#Dror Helper
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?
Colin Riley
 
Delegates and events
Delegates and events   Delegates and events
Delegates and events
Gayathri Ganesh
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
BG Java EE Course
 
Open Plan Presentation
Open Plan PresentationOpen Plan Presentation
Open Plan Presentation
Farrukh Rasheed
 
Algorithms
AlgorithmsAlgorithms
Algorithms
Liam Dunphy
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to PseudocodeDamian T. Gordon
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
Nishith Shukla
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examples
Gautam Roy
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowchartsnicky_walters
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 

Viewers also liked (20)

Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)
 
Basics of oops concept
Basics of oops conceptBasics of oops concept
Basics of oops concept
 
OOP Basics
OOP BasicsOOP Basics
OOP Basics
 
Technical Excellence - OOP Munich 2015
Technical Excellence - OOP Munich 2015Technical Excellence - OOP Munich 2015
Technical Excellence - OOP Munich 2015
 
Delegates in C#
Delegates in C#Delegates in C#
Delegates in C#
 
Flow chart and pseudo code
Flow chart and pseudo code Flow chart and pseudo code
Flow chart and pseudo code
 
Fluent interface in c#
Fluent interface in c#Fluent interface in c#
Fluent interface in c#
 
interface in c#
interface in c#interface in c#
interface in c#
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Delegates and events
Delegates and events   Delegates and events
Delegates and events
 
C# Delegates
C# DelegatesC# Delegates
C# Delegates
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Open Plan Presentation
Open Plan PresentationOpen Plan Presentation
Open Plan Presentation
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examples
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 

Similar to Total oop in c# dot net

OOP programming
OOP programmingOOP programming
OOP programminganhdbh
 
IntroToOOP.ppt
IntroToOOP.pptIntroToOOP.ppt
IntroToOOP.ppt
ssuser2d043c
 
IntroT.ppt
IntroT.pptIntroT.ppt
IntroT.ppt
WrushabhShirsat3
 
IntroToOOP.ppt
IntroToOOP.pptIntroToOOP.ppt
IntroToOOP.ppt
kavitamittal18
 
IntroToOOP.ppt
IntroToOOP.pptIntroToOOP.ppt
IntroToOOP.ppt
kthejeswari
 
IntroToOOP.ppt
IntroToOOP.pptIntroToOOP.ppt
IntroToOOP.ppt
kthejeswari
 
1 intro
1 intro1 intro
1 intro
abha48
 
Object oriented design-UNIT V
Object oriented design-UNIT VObject oriented design-UNIT V
Object oriented design-UNIT V
Azhar Shaik
 
MCA NOTES.pdf
MCA NOTES.pdfMCA NOTES.pdf
MCA NOTES.pdf
RAJASEKHARV10
 
Programming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdfProgramming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdf
swapnilslide2019
 
java tr.docx
java tr.docxjava tr.docx
java tr.docx
harishkuna4
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
TigistTilahun1
 
Ooad notes
Ooad notesOoad notes
Ooad notes
NancyJP
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
IthagoniShirisha
 
Basics of object oriented programming c++ [autosaved]
Basics of object oriented programming c++ [autosaved]Basics of object oriented programming c++ [autosaved]
Basics of object oriented programming c++ [autosaved]
RAVIPUROHIT22
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
Intro tooop
Intro tooopIntro tooop
Intro tooop
Parameshwar Maddela
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_javaSelf
 

Similar to Total oop in c# dot net (20)

OOP programming
OOP programmingOOP programming
OOP programming
 
IntroToOOP.ppt
IntroToOOP.pptIntroToOOP.ppt
IntroToOOP.ppt
 
IntroT.ppt
IntroT.pptIntroT.ppt
IntroT.ppt
 
IntroToOOP.ppt
IntroToOOP.pptIntroToOOP.ppt
IntroToOOP.ppt
 
IntroToOOP.ppt
IntroToOOP.pptIntroToOOP.ppt
IntroToOOP.ppt
 
IntroToOOP.ppt
IntroToOOP.pptIntroToOOP.ppt
IntroToOOP.ppt
 
1 intro
1 intro1 intro
1 intro
 
Object oriented design-UNIT V
Object oriented design-UNIT VObject oriented design-UNIT V
Object oriented design-UNIT V
 
MCA NOTES.pdf
MCA NOTES.pdfMCA NOTES.pdf
MCA NOTES.pdf
 
Programming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdfProgramming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdf
 
Java pdf
Java   pdfJava   pdf
Java pdf
 
java tr.docx
java tr.docxjava tr.docx
java tr.docx
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
 
Ooad notes
Ooad notesOoad notes
Ooad notes
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
 
Basics of object oriented programming c++ [autosaved]
Basics of object oriented programming c++ [autosaved]Basics of object oriented programming c++ [autosaved]
Basics of object oriented programming c++ [autosaved]
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programming
 
Intro tooop
Intro tooopIntro tooop
Intro tooop
 
Intro Uml
Intro UmlIntro Uml
Intro Uml
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_java
 

Recently uploaded

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 

Recently uploaded (20)

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 

Total oop in c# dot net

  • 1. PROPAGATING IN .NET By Muhammad Naveed MCS University of AJK, DIT Instructor Moon Creations School of IT 1
  • 2. OOP  Function +data  In modular programming functions and data is separated.  i.e. student { Student info } Courses { Course info. } 210/13/2012Muhammad Naveed
  • 3. OOP  So every thing is separated data and operations .  Class is an instance of an object, which defines state and behavior of an object.  Object can interacts with each other by message passing. 310/13/2012Muhammad Naveed
  • 4. Class  To house (among other things)  In class we provide one or more methods that are designed to perform the class tasks.  For example: a bank account class might contain one or more methods to deposit money, withdraw money and balance inquiry.  Collection of similar objects, with different names  Class in an passive entity.  Class in template or blue print  Class is module or sketch.  Class has data members and functions on which class performs its functionalities.  Data and functions are combined 410/13/2012Muhammad Naveed
  • 5. Object  We have to build a object of class to actually gets its fruits. C# called OOP  Object is an active entity.  Object has properties or methods/ attitudes/ functions/operations/data members/fields  So objects has state and behaviors  Students is an object.  Employee is an object 510/13/2012Muhammad Naveed
  • 6. Methods  Performing a task in an application requires a method. The method describes the mechanism that actually perform its task. The method hides from its user the complex tasks. Just as the accelerator pedal of a car hides from the driver the complex mechanism of making the car go faster. 610/13/2012Muhammad Naveed
  • 7. Attributes  Every objects muse have some attributes or properties like color, size, shape etc.  Attributes are specified by the class’ instance variables  Properties Get assessors and set assessors  Attributes are not necessarily accessible directly. The car manufacturer does not want drivers to take apart the car’s engine to observe the amount of gas in its tank.  Instead the driver can check the fuel gauge on the dashboard.  So in c# we use get accessors for reading and set accessors for storing values. 710/13/2012Muhammad Naveed
  • 8. STATIC Methods  Sometimes a method performs a task that does not depend on the contents of any object. So can be called with out creating its object this is called static method.  Syntax  ClassName. MethodName(arguments)  Always called with class name and method name 810/13/2012Muhammad Naveed
  • 10. Constructor  Constructor is used to initialize the object of the class.  Behaves like Function  Constructor is just like function, but it is a special type of function.  Same name like class  Class student  Public student( )  Defaults constructor has no argument or parameters 1010/13/2012Muhammad Naveed
  • 11. Properties Function  These are get and set functions  Not a fully function but behaves like function.  Used to get and set values of private data members of a class 1110/13/2012Muhammad Naveed
  • 12.  int n;  Console.WriteLine("Enter a number");  n = Convert.ToInt32(Console.ReadLine());  if (n > 0)  {  Console.WriteLine("The Number is +ve");  }  else  {  Console.WriteLine("The number is -ve");  }  Console.Read();  int n;  n = 1;  while (n <= 5)  {  Console.WriteLine("Kashmir");  n++;  }  Console.Read(); 1210/13/2012Muhammad Naveed
  • 13. Major Concepts  OOP  Classes  Objects  Methods  Properties  Instance Variables 1310/13/2012Muhammad Naveed
  • 16. Features of OOP  Inheritance  Polymorphism  Encapsulation  Abstraction 1610/13/2012Muhammad Naveed
  • 17. STRUCTURED VS. OO PROGRAMMING 17 STRUCTURED PROGRAMMING: 10/13/2012Muhammad Naveed
  • 18. Structured Programming  Using function  Function & program is divided into modules  Every module has its own data and function which can be called by other modules. 1810/13/2012Muhammad Naveed
  • 20. OBJECT ORIENTED PROGRAMMING Objects have both data and methods Objects of the same class have the same data elements and methods Objects send and receive messages to invoke actions Key idea in object-oriented: The real world can be accurately described as a collection of objects that interact. 2010/13/2012Muhammad Naveed
  • 21. Basic terminology object - usually a person, place or thing (a noun) method - an action performed by an object (a verb) attribute - description of objects in a class class - a category of similar objects (such as automobiles) - does not hold any values of the object’s attributes 2110/13/2012Muhammad Naveed
  • 22. Example for attributes and methods Attributes:  manufacturer’s name  model name  year made  color  number of doors  size of engine  etc. Methods:  Define data items (specify manufacturer’s name, model, year, etc.)  Change a data item (color, engine, etc.)  Display data items  Calculate cost  etc. 2210/13/2012Muhammad Naveed
  • 23. WHY OOP? Save development time (and cost) by reusing code once an object class is created it can be used in other applications Easier debugging classes can be tested independently reused objects have already been tested 2310/13/2012Muhammad Naveed
  • 24. DESIGN PRINCIPLES OF OOP Four main design principles of Object-Oriented Programming(OOP): Encapsulation(information hiding) Abstraction(hide unnecessary details ) Polymorphism(same thing behave differently) Inheritance(derived class inherit from base class) 2410/13/2012Muhammad Naveed
  • 25. ENCAPSULATION Also known as data hiding Only object’s methods can modify information in the object. Data and Function Encapsulated within a single package ‘class’. Analogy: ATM machine can only update accounts of one person or object only. 2510/13/2012Muhammad Naveed
  • 26. Abstraction  Focus only on the important facts about the problem at hand  to design, produce, and describe so that it can be easily used without knowing the details of how it works. Analogy:  When you drive a car, you don’t have to know how the gasoline and air are mixed and ignited.  Instead you only have to know how to use the controls.  Draw map 2610/13/2012Muhammad Naveed
  • 27. POLYMORPHISM the same word or phrase can mean different things in different contexts Analogy: In English, bank can mean side of a river or a place to put money move - 2710/13/2012Muhammad Naveed
  • 28. Function Overloading  The operation of one function depends on the argument passed to it.  Example: Fly(), Fly(low), Fly(150) 2810/13/2012Muhammad Naveed
  • 29. INHERITANCE Inheritance—a way of organizing classes Term comes from inheritance of traits like eye color, hair color, and so on. Classes with properties in common can be grouped so that their common properties are only defined once. Superclass – inherit its attributes & methods to the subclass(es). Subclass – can inherit all its superclass attributes & methods besides having its own unique attributes & methods. 2910/13/2012Muhammad Naveed
  • 30. AN INHERITANCE HIERARCHY 30 Vehicle Automobile Motorcycle Bus Sedan Sports Car School BusLuxury Bus What properties does each vehicle inherit from the types of vehicles above it in the diagram? Superclass Subclasses 10/13/2012Muhammad Naveed
  • 31. OBJECT-ORIENTED PROGRAMMING LANGUAGES  Pure OO Languages C#, Smalltalk, Eiffel, Actor, Java  Hybrid OO Languages C++, Objective-C, Object-Pascal 3110/13/2012Muhammad Naveed
  • 32. Review: Introduction to Object Orientation  What are the four basic principles of object orientation? Provide a brief description of each.  What is an Object and what is a Class? What is the difference between them?  What is an Attribute?  What is an Operation?  What is inheritance?  What is polymorphism?  Describe the strengths of object orientation. 3210/13/2012Muhammad Naveed
  • 33. Review: Introduction to Object Orientation  State 2 differences between functional programming and OOP.  What are the four basic principles of object orientation? Provide a brief description of each.  What is an Object and what is a Class? What is the difference between them?  What is an Attribute?  What is an Operation?  Describe the strengths of object orientation. 3310/13/2012Muhammad Naveed
  • 34. Polymorphism  Compile time polymorphism(Overloading)  Run time Polymorphism( Overriding ) 3410/13/2012Muhammad Naveed
  • 35. Compile Time Polymorphism(Overloading)  Can be Achieved by  Function Overloading  Operator Overloading  Constructor Overloading 3510/13/2012Muhammad Naveed
  • 36. Compile Time Polymorphism(Overloading)  Function Overloading  It means same thing behaves differently  Public void get()  Public void get(int r)  Public void get(int r, string n)  Public void get(int r, string n, string rem….)  So same function behaves differently by increasing number of parameters or arguments i.e. no argument, one argument or two or may be three or even more.  So this is how we can achieve Compile time polymorphism that is overloading  Also function type or signature can be changed, so that it can be define with same name but with different parameters. 3610/13/2012Muhammad Naveed
  • 38. Compile Time Polymorphism(Overloading)  Operator Overloading  Some operators can also behaves differently called operator overloading (polymorphism). Operator can be redefined to achieve the operator overloading. 3810/13/2012Muhammad Naveed
  • 45. Compile Time Polymorphism(Overloading)  3. Constructor Overloading 4510/13/2012Muhammad Naveed
  • 50. Lecture  Intro to GUI using C#  Windows Applications  Windows Forms 5010/13/2012Muhammad Naveed
  • 51. Run Time Polymorphism (Overriding)  We have learned about compile time polymorphism which is overloading.  Function Overloading  Public void get(int n)  Operator Overloading  Public static room operaotr +(room rm1, room rm2)  Constructor Overloading  Public student(string n,…) 5110/13/2012Muhammad Naveed
  • 52. Run Time Polymorphism (Overriding)  Now in this case we have to change the signature or nos of parameters to get function overloading. Which we have done.  But in some situations, we have to use same function with the same name signature this is called overriding. this situation can be used in parent class relationship i.e.  Where we have to use virtual function, That needs to be redefined again and again. It gives the 1st definition of that function, 5210/13/2012Muhammad Naveed
  • 53. Run Time Polymorphism (Overriding)  Because same name with same signature needs to be redefined using virtual keyword in the parent class.  And to access this in the child class we have to use override keyword. 5310/13/2012Muhammad Naveed
  • 55. OOP: Inheritance  Inheritance a form of software reuse.  Lets you save much of your time in software development.  The existing class from which a new class inherits is called base class, and the new class is called derived class  Each derived class can become the base class for next extended class  And new data members can be added. 10/13/2012Muhammad Naveed 55
  • 56. OOP: Inheritance Base Class Derived Class Student Graduate Student, Undergradulate Shape Oval, Rectangle, elpse Loan CarLoan, HomeLoan BankAccount Currant, Saving etc 10/13/2012Muhammad Naveed 56
  • 57. OOP: Inheritance 10/13/2012Muhammad Naveed 57 Community Member Employee Faculty Admin Teacher Staff Student Alumnus
  • 58. OOP: Inheritance  Protected Members  Commonly we used Public and Private  Public data members are accessible whenever the application has a reference to an object of that class or one of its derived class.  Private data members are inherited from its derived class, but are not accessible by derived class and methods. 10/13/2012Muhammad Naveed 58
  • 59. OOP: Inheritance  Protected :  Provides an intermediate level of accessibility b/w public and private. These can be accessible by members of that base class and by members of its derived class 10/13/2012Muhammad Naveed 59
  • 60. Relationship b/w base classes and derived classes 10/13/2012Muhammad Naveed 60
  • 66.  The above examples show polymorphism, inheritance, constructor overloading and function overloading, private and public data members w.r.t access.  Reference Book  C# 2010 for programmers.  Chapter 11, OOP Programming: inheritance page:320 etc 10/13/2012Muhammad Naveed 66 summery
  • 67. Abstract Class and Methods  We can not create object of the Abstract Class.  The purpose of the abstract class is primarily to provide and appropriate base class from which other classes can inherit and thus share a common design.  Public abstract void show()//abstract method 10/13/2012Muhammad Naveed 67
  • 69. Payroll System Using Polymorphism  A company pay in employees on a weekly basis.  The employees are of four types.  Salaried Employees: are paid a fixed weekly salary regardless of the number of hours worked.  Hourly Employees: are paid by hour and receive “time and a half” overtime pay for their sales.  Salaried commission employees: are paid a percentage of their sales.  For the current pay period the company has decides to reward salaried commission employees by adding 10% to their base salaries.  Company demands a C# application. 10/13/2012Muhammad Naveed 69
  • 70. Solution  We use abstract class as employee for general concept.  The other class that extends from employee abstract class are: SalariedEmployee, CommissionEmployee and HourlyEmployee.  ClassBasePlusCommissioEmployee Which extends from CommissionEmployee.  UML 10/13/2012Muhammad Naveed 70
  • 72. Cases Classes Earnigns ToString Employee Abstract The abstract class for all other classes as a foundation first name,last name, social security number SSN Salaried Employee weeklySalary Salaried employee:employee Weekly salary: Hourly Employee If hours<=40 Wage=hours Ifhours>40 40*wage+(hours- 40)+wage=1.5 Hourlty employee:employee Houtly wage :wage Hours work:hours Comission Employee commissionRate*grossS ales Inherit from employee Gross sale:grassSales Comission rate:comissionRate BasePlusComissionEmpl oyee comissionRate*grossSal es+baseSalry Base Salaried comsiion employee:10/13/2012Muhammad Naveed 72
  • 73. Solution Book page no344 10/13/2012Muhammad Naveed 73
  • 74. Exception Handling  Try  {  Throuth exception()  }  Catch  {  Catch exception()  }  Finally  {  Show final()  } 10/13/2012Muhammad Naveed 74
  • 76. GUI : Windows Forms 10/13/2012Muhammad Naveed 76
  • 77. Events And Handling them 10/13/2012Muhammad Naveed 77