SlideShare a Scribd company logo
1 of 21
Object-Oriented Programming Using C#
Objectives


               In this session, you will learn to:
                  Implement operator overloading
                  Identify relationships between classes
                  Use classes and inheritance




    Ver. 1.0                        Session 10             Slide 1 of 21
Object-Oriented Programming Using C#
Overloading Unary Operators


               Unary operators act on a single operand. Some examples
               of unary operators are the increment (++) and decrement
               (--) operators.
               Unary operators can be classified as:
                  Simple prefix unary operators, for example the – (minus)
                  operator.
                  Pre and post increment and decrement operators, for example
                  the ++() prefix increment operator.
               The implementation of the increment operator used with
               structs cannot be implemented with classes.




    Ver. 1.0                      Session 10                          Slide 2 of 21
Object-Oriented Programming Using C#
Overloading Binary Operators


               Binary operators are operators that work with two operands.
               Binary operators include the arithmetic operators (+, -, *, /,
               %), arithmetic assignment operators (+=, -=, *=, /=. %=),
               and comparison operators (<, >, <=, >=, ==, !=).
               Overloading a binary operator is similar to overloading a
               unary operator, except that a binary operator requires an
               additional parameter.
               Following is the syntax of binary overloading in C#:
                operator <operator>(Object1,Object2);




    Ver. 1.0                      Session 10                         Slide 3 of 21
Object-Oriented Programming Using C#
Demo: Overloading an Operator


               Problem Statement:
                  FunCity Land is a newly established amusement park located
                  in West Virginia. Brad is a chief technical officer of FunCity
                  Land. He is currently working on a project related with
                  calculating distances. This project will calculate the distance to
                  reach FunCity Land from various locations because many
                  visitors do not know the exact location of the park.
                  Brad needs to develop a program, which would enter a visitor’s
                  location and the distance traveled by the visitor till that point.
                  After analyzing the location and the distance traveled by the
                  visitor, the program should display the remaining distance and
                  the total distance traveled.
                  Help Brad to develop an application by overloading the binary
                  operator(+).



    Ver. 1.0                        Session 10                             Slide 4 of 21
Object-Oriented Programming Using C#
Demo: Overloading an Operator (Contd.)


               Solution:
                  To develop the required application, Brad needs to perform the
                  following tasks:
                   1. Create a console-based application.
                   2. Build and execute an application.




    Ver. 1.0                        Session 10                          Slide 5 of 21
Object-Oriented Programming Using C#
Identifying Relationships Between Classes


               In software application, classes and objects are related to
               each other.
               In the object-oriented approach, objects perform actions in
               response to messages from other objects defining the
               recipient object’s behavior.
               This approach specifies the relationships among classes
               based on the behavior of individual class.




    Ver. 1.0                      Session 10                        Slide 6 of 21
Object-Oriented Programming Using C#
Kinds of Relationships


               There are various relationships between objects of different
               classes in an object-oriented environment:
                  Inheritance Relationship:
                      Object-oriented programming enables classes to inherit commonly
                      used state and behavior from other classes.
                      In C# programming, a class is allowed to inherit from another
                      class.
                      Generalization is needed to create programs that can be
                      customized in accordance with new requirements.
               Let us understand the concept of inheritance relationship
               with the help of an example.




    Ver. 1.0                        Session 10                              Slide 7 of 21
Object-Oriented Programming Using C#
Kinds of Relationships (Contd.)


                         Parent Class




    Ver. 1.0                  Session 10   Slide 8 of 21
Object-Oriented Programming Using C#
Kinds of Relationships (Contd.)



                                          Parent Class




                                           Child Class




    Ver. 1.0                 Session 10                  Slide 9 of 21
Object-Oriented Programming Using C#
Kinds of Relationships (Contd.)


                                          Parent Class




                                          Child Class
                                          Deriving the features of parents,
                                          such as height, complexion, and
                                          Behavior


    Ver. 1.0                 Session 10                           Slide 10 of 21
Object-Oriented Programming Using C#
Kinds of Relationships (Contd.)


               You can also establish a relationship between a superclass
               and its subclasses.
               The following figure shows the hierarchy of the subclasses
               of a superclass.
                                      Automobile




                                Car                 Bus




                         Ford    BMW           Toyota     Mitsubishi




    Ver. 1.0                           Session 10                      Slide 11 of 21
Object-Oriented Programming Using C#
Kinds of Relationships (Contd.)


               • Composition Relationship:
                     Object-oriented programming allows you to form an object,
                     which includes another object as its part. This mechanism of
                     forming an object is called composition.
               • Utilization Relationship:
                     Object-oriented programming allows a class to make use of
                     another class. This kind of relationship is called utilization.
               • Instantiation Relationship:
                     Object-oriented programming allows a relationship between a
                     class and an instance of that class. This kind of relationship is
                     called instantiation.




    Ver. 1.0                           Session 10                              Slide 12 of 21
Object-Oriented Programming Using C#
Just a minute


               Build the hierarchy of the mixer, VCR, color television,
               washing machine, stereo class objects, and generalize
               wherever possible.


               Answer:
                  The figure shows the hierarchy of the class objects.

                                                         Electronic Items




                         Entertainment Items                                    Utility Items




                    Color             VCR           Stereo                               Washing
                                                                        Mixer
                    Television                                                           Machine




    Ver. 1.0                                   Session 10                                          Slide 13 of 21
Object-Oriented Programming Using C#
Just a minute


               Identify the relationship between the following class pairs:
                1.   Television – Speaker
                2.   Mammal – Tiger
                3.   Garment – Shirt
                4.   Cup – Tea
                5.   Computer – Microprocessor


               Answer:
                     5 and 1 are examples of composition relationships.
                     3 and 2 are examples of inheritance relationships.
                     4 does not exhibit any relationship. Tea is not an attribute of
                     cup.




    Ver. 1.0                          Session 10                              Slide 14 of 21
Object-Oriented Programming Using C#
Just a minute


               Identify the classes and their utilization relationship in the
               following scenario of a departmental store.
               There are several counters and each counter in the store is
               manned by a single salesperson who sells a specific
               product. A customer approaches a counter. Depending on
               the customer’s desire to purchase a product, the
               salesperson sells the product to the customer and accepts
               payment.

               Answer:
                  The utilization relationship of the preceding scenario are:
                      Salespersons man the counters.
                      Each counter deals in a specific product.
                      The customer buys a product.
                      The customer pays the salesperson.


    Ver. 1.0                         Session 10                            Slide 15 of 21
Object-Oriented Programming Using C#
Using Classes and Inheritance


               In C#, inheritance is the property by which the objects of a
               derived class possess copies of the data members and the
               member functions of the base class.
               A class that inherits or derives attributes from another class
               is called the derived class.
               The class from which attributes are derived is called the
               base class.
               In object-oriented programming, the base class is actually a
               superclass and the derived class is a subclass.




    Ver. 1.0                       Session 10                        Slide 16 of 21
Object-Oriented Programming Using C#
Implementing Inheritance


               Each instance of the derived class includes the attributes of
               the base class.
               Any change made to the base class automatically changes
               the behavior of its derived classes.
               The syntax used in C# for creating derived classes is as
               follows:
                  <access-specifier> class <base_class>
                  {
                      ...
                  }
                      class <derived_class> : <base_class>
                  {
                      ...
                  }

    Ver. 1.0                      Session 10                         Slide 17 of 21
Object-Oriented Programming Using C#
Implementing Inheritance (Contd.)


               You can use the following thumb rule to establish whether
               inheritance is required while you are designing a program.
               Always check the kind of relationship between the derived
               and the base class.
                  Ensure that the derived class can base class.
                  You can also use inherited classes with constructors.
                  In inheritance, the derived class receives the base class
                  member variables and methods. This means that an order of
                  inheritance must be followed during the construction of an
                  object.




    Ver. 1.0                      Session 10                          Slide 18 of 21
Object-Oriented Programming Using C#
Summary


              In this session, you learned that:
                 Operators may be classified as unary and binary operators.
                 Unary operators work with one operand and are classified as:
                  •   Simple prefix unary operators
                  •   Pre and post increment and decrement operators
               – A prefix unary operator may be defined by a member function
                 that takes no parameters or by a nonmember function that
                 takes one parameter.
               – Binary operators work with two operands.
               – Overloading a binary operator is similar to overloading a unary
                 operator, except that a binary operator requires an additional
                 parameter.




   Ver. 1.0                         Session 10                          Slide 19 of 21
Object-Oriented Programming Using C#
Summary (Contd.)


                 The four kinds of relationships that exist among classes are:
                  •   Inheritance relationship
                  •   Composition relationship
                  •   Utilization relationship
                  •   Instantiation relationship
               – Object-oriented programming enables classes to inherit
                 commonly used state and behavior from other classes.
               – Generalization means that multiple classes can inherit from the
                 same superclass.
               – The composition relationship exists when one class is made up
                 of another class.
               – The utilization relationship exists between two or more
                 unrelated classes if one class uses the other.




    Ver. 1.0                          Session 10                        Slide 20 of 21
Object-Oriented Programming Using C#
Summary (Contd.)


               An instantiation relationship is a relationship between a class
               and an instance of that class.
               A class that inherits or derives attributes from another class is
               called the derived class and the class from which it is derived
               is called the base class.
               Inheritance avoids redundancy in code and enables easy
               maintenance of code.
               Constructors are called in the order of base-to-derived.




    Ver. 1.0                     Session 10                             Slide 21 of 21

More Related Content

What's hot

09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13Niit Care
 
13 iec t1_s1_oo_ps_session_19
13 iec t1_s1_oo_ps_session_1913 iec t1_s1_oo_ps_session_19
13 iec t1_s1_oo_ps_session_19Niit Care
 
03 iec t1_s1_oo_ps_session_04
03 iec t1_s1_oo_ps_session_0403 iec t1_s1_oo_ps_session_04
03 iec t1_s1_oo_ps_session_04Niit Care
 
Java session02
Java session02Java session02
Java session02Niit Care
 
Java session01
Java session01Java session01
Java session01Niit Care
 
02 iec t1_s1_plt_session_02
02 iec t1_s1_plt_session_0202 iec t1_s1_plt_session_02
02 iec t1_s1_plt_session_02Niit Care
 
Java session11
Java session11Java session11
Java session11Niit Care
 
Write native iPhone applications using Eclipse CDT
Write native iPhone applications using Eclipse CDTWrite native iPhone applications using Eclipse CDT
Write native iPhone applications using Eclipse CDTAtit Patumvan
 
Oop02 6
Oop02 6Oop02 6
Oop02 6schwaa
 
Oop04 6
Oop04 6Oop04 6
Oop04 6schwaa
 
4.class diagramsusinguml
4.class diagramsusinguml4.class diagramsusinguml
4.class diagramsusingumlAPU
 
Win32/Flamer: Reverse Engineering and Framework Reconstruction
Win32/Flamer: Reverse Engineering and Framework ReconstructionWin32/Flamer: Reverse Engineering and Framework Reconstruction
Win32/Flamer: Reverse Engineering and Framework ReconstructionAlex Matrosov
 
Evolution of Patterns
Evolution of PatternsEvolution of Patterns
Evolution of PatternsChris Eargle
 

What's hot (20)

09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13
 
13 iec t1_s1_oo_ps_session_19
13 iec t1_s1_oo_ps_session_1913 iec t1_s1_oo_ps_session_19
13 iec t1_s1_oo_ps_session_19
 
03 iec t1_s1_oo_ps_session_04
03 iec t1_s1_oo_ps_session_0403 iec t1_s1_oo_ps_session_04
03 iec t1_s1_oo_ps_session_04
 
01 gui 01
01 gui 0101 gui 01
01 gui 01
 
Java session02
Java session02Java session02
Java session02
 
Java session01
Java session01Java session01
Java session01
 
02 iec t1_s1_plt_session_02
02 iec t1_s1_plt_session_0202 iec t1_s1_plt_session_02
02 iec t1_s1_plt_session_02
 
Java session11
Java session11Java session11
Java session11
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 
Write native iPhone applications using Eclipse CDT
Write native iPhone applications using Eclipse CDTWrite native iPhone applications using Eclipse CDT
Write native iPhone applications using Eclipse CDT
 
 
Dacj 1-2 a
Dacj 1-2 aDacj 1-2 a
Dacj 1-2 a
 
C Course Material0209
C Course Material0209C Course Material0209
C Course Material0209
 
Oop02 6
Oop02 6Oop02 6
Oop02 6
 
Oop04 6
Oop04 6Oop04 6
Oop04 6
 
4.class diagramsusinguml
4.class diagramsusinguml4.class diagramsusinguml
4.class diagramsusinguml
 
Fudcon D programming
Fudcon D programmingFudcon D programming
Fudcon D programming
 
Csharp
CsharpCsharp
Csharp
 
Win32/Flamer: Reverse Engineering and Framework Reconstruction
Win32/Flamer: Reverse Engineering and Framework ReconstructionWin32/Flamer: Reverse Engineering and Framework Reconstruction
Win32/Flamer: Reverse Engineering and Framework Reconstruction
 
Evolution of Patterns
Evolution of PatternsEvolution of Patterns
Evolution of Patterns
 

Viewers also liked

Viewers also liked (6)

Threading
ThreadingThreading
Threading
 
multi threading
multi threadingmulti threading
multi threading
 
C# Advanced L04-Threading
C# Advanced L04-ThreadingC# Advanced L04-Threading
C# Advanced L04-Threading
 
Threads c sharp
Threads c sharpThreads c sharp
Threads c sharp
 
C# Delegates and Event Handling
C# Delegates and Event HandlingC# Delegates and Event Handling
C# Delegates and Event Handling
 
Threading in c#
Threading in c#Threading in c#
Threading in c#
 

Similar to 07 iec t1_s1_oo_ps_session_10

Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)John Smith
 
Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Wes Yanaga
 
Reuse Contracts
Reuse ContractsReuse Contracts
Reuse ContractsESUG
 
Java Programming
Java ProgrammingJava Programming
Java ProgrammingTracy Clark
 
Object Oriented Software Development, using c# programming language
Object Oriented Software Development, using c# programming languageObject Oriented Software Development, using c# programming language
Object Oriented Software Development, using c# programming languageGeorges Abboudeh
 
Answer all questions and discussions.1.Describe what is an.docx
Answer all questions and discussions.1.Describe what is an.docxAnswer all questions and discussions.1.Describe what is an.docx
Answer all questions and discussions.1.Describe what is an.docxlisandrai1k
 
Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design patternchetankane
 
Prophecy Of Design Patterns
Prophecy Of Design PatternsProphecy Of Design Patterns
Prophecy Of Design Patternspradeepkothiyal
 
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)ssuser7f90ae
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...NicheTech Com. Solutions Pvt. Ltd.
 
HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12Aditi Bhushan
 
Bca2030 object oriented programming – c++
Bca2030   object oriented programming – c++Bca2030   object oriented programming – c++
Bca2030 object oriented programming – c++smumbahelp
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsMichael Heron
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.pptTigistTilahun1
 

Similar to 07 iec t1_s1_oo_ps_session_10 (20)

Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)
 
Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)
 
Programming with c#
Programming with c#Programming with c#
Programming with c#
 
Programming in c#
Programming in c#Programming in c#
Programming in c#
 
Reuse Contracts
Reuse ContractsReuse Contracts
Reuse Contracts
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Object Oriented Software Development, using c# programming language
Object Oriented Software Development, using c# programming languageObject Oriented Software Development, using c# programming language
Object Oriented Software Development, using c# programming language
 
Answer all questions and discussions.1.Describe what is an.docx
Answer all questions and discussions.1.Describe what is an.docxAnswer all questions and discussions.1.Describe what is an.docx
Answer all questions and discussions.1.Describe what is an.docx
 
Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design pattern
 
Prophecy Of Design Patterns
Prophecy Of Design PatternsProphecy Of Design Patterns
Prophecy Of Design Patterns
 
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
 
Csharp
CsharpCsharp
Csharp
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
 
IOSR Journals
IOSR JournalsIOSR Journals
IOSR Journals
 
HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12
 
C#
C#C#
C#
 
Uday Resume
Uday ResumeUday Resume
Uday Resume
 
Bca2030 object oriented programming – c++
Bca2030   object oriented programming – c++Bca2030   object oriented programming – c++
Bca2030 object oriented programming – c++
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design Patterns
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 b
Dacj 1-3 bDacj 1-3 b
Dacj 1-3 b
 

Recently uploaded

State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...ScyllaDB
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiRaviKumarDaparthi
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 

Recently uploaded (20)

State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi Daparthi
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 

07 iec t1_s1_oo_ps_session_10

  • 1. Object-Oriented Programming Using C# Objectives In this session, you will learn to: Implement operator overloading Identify relationships between classes Use classes and inheritance Ver. 1.0 Session 10 Slide 1 of 21
  • 2. Object-Oriented Programming Using C# Overloading Unary Operators Unary operators act on a single operand. Some examples of unary operators are the increment (++) and decrement (--) operators. Unary operators can be classified as: Simple prefix unary operators, for example the – (minus) operator. Pre and post increment and decrement operators, for example the ++() prefix increment operator. The implementation of the increment operator used with structs cannot be implemented with classes. Ver. 1.0 Session 10 Slide 2 of 21
  • 3. Object-Oriented Programming Using C# Overloading Binary Operators Binary operators are operators that work with two operands. Binary operators include the arithmetic operators (+, -, *, /, %), arithmetic assignment operators (+=, -=, *=, /=. %=), and comparison operators (<, >, <=, >=, ==, !=). Overloading a binary operator is similar to overloading a unary operator, except that a binary operator requires an additional parameter. Following is the syntax of binary overloading in C#: operator <operator>(Object1,Object2); Ver. 1.0 Session 10 Slide 3 of 21
  • 4. Object-Oriented Programming Using C# Demo: Overloading an Operator Problem Statement: FunCity Land is a newly established amusement park located in West Virginia. Brad is a chief technical officer of FunCity Land. He is currently working on a project related with calculating distances. This project will calculate the distance to reach FunCity Land from various locations because many visitors do not know the exact location of the park. Brad needs to develop a program, which would enter a visitor’s location and the distance traveled by the visitor till that point. After analyzing the location and the distance traveled by the visitor, the program should display the remaining distance and the total distance traveled. Help Brad to develop an application by overloading the binary operator(+). Ver. 1.0 Session 10 Slide 4 of 21
  • 5. Object-Oriented Programming Using C# Demo: Overloading an Operator (Contd.) Solution: To develop the required application, Brad needs to perform the following tasks: 1. Create a console-based application. 2. Build and execute an application. Ver. 1.0 Session 10 Slide 5 of 21
  • 6. Object-Oriented Programming Using C# Identifying Relationships Between Classes In software application, classes and objects are related to each other. In the object-oriented approach, objects perform actions in response to messages from other objects defining the recipient object’s behavior. This approach specifies the relationships among classes based on the behavior of individual class. Ver. 1.0 Session 10 Slide 6 of 21
  • 7. Object-Oriented Programming Using C# Kinds of Relationships There are various relationships between objects of different classes in an object-oriented environment: Inheritance Relationship: Object-oriented programming enables classes to inherit commonly used state and behavior from other classes. In C# programming, a class is allowed to inherit from another class. Generalization is needed to create programs that can be customized in accordance with new requirements. Let us understand the concept of inheritance relationship with the help of an example. Ver. 1.0 Session 10 Slide 7 of 21
  • 8. Object-Oriented Programming Using C# Kinds of Relationships (Contd.) Parent Class Ver. 1.0 Session 10 Slide 8 of 21
  • 9. Object-Oriented Programming Using C# Kinds of Relationships (Contd.) Parent Class Child Class Ver. 1.0 Session 10 Slide 9 of 21
  • 10. Object-Oriented Programming Using C# Kinds of Relationships (Contd.) Parent Class Child Class Deriving the features of parents, such as height, complexion, and Behavior Ver. 1.0 Session 10 Slide 10 of 21
  • 11. Object-Oriented Programming Using C# Kinds of Relationships (Contd.) You can also establish a relationship between a superclass and its subclasses. The following figure shows the hierarchy of the subclasses of a superclass. Automobile Car Bus Ford BMW Toyota Mitsubishi Ver. 1.0 Session 10 Slide 11 of 21
  • 12. Object-Oriented Programming Using C# Kinds of Relationships (Contd.) • Composition Relationship: Object-oriented programming allows you to form an object, which includes another object as its part. This mechanism of forming an object is called composition. • Utilization Relationship: Object-oriented programming allows a class to make use of another class. This kind of relationship is called utilization. • Instantiation Relationship: Object-oriented programming allows a relationship between a class and an instance of that class. This kind of relationship is called instantiation. Ver. 1.0 Session 10 Slide 12 of 21
  • 13. Object-Oriented Programming Using C# Just a minute Build the hierarchy of the mixer, VCR, color television, washing machine, stereo class objects, and generalize wherever possible. Answer: The figure shows the hierarchy of the class objects. Electronic Items Entertainment Items Utility Items Color VCR Stereo Washing Mixer Television Machine Ver. 1.0 Session 10 Slide 13 of 21
  • 14. Object-Oriented Programming Using C# Just a minute Identify the relationship between the following class pairs: 1. Television – Speaker 2. Mammal – Tiger 3. Garment – Shirt 4. Cup – Tea 5. Computer – Microprocessor Answer: 5 and 1 are examples of composition relationships. 3 and 2 are examples of inheritance relationships. 4 does not exhibit any relationship. Tea is not an attribute of cup. Ver. 1.0 Session 10 Slide 14 of 21
  • 15. Object-Oriented Programming Using C# Just a minute Identify the classes and their utilization relationship in the following scenario of a departmental store. There are several counters and each counter in the store is manned by a single salesperson who sells a specific product. A customer approaches a counter. Depending on the customer’s desire to purchase a product, the salesperson sells the product to the customer and accepts payment. Answer: The utilization relationship of the preceding scenario are: Salespersons man the counters. Each counter deals in a specific product. The customer buys a product. The customer pays the salesperson. Ver. 1.0 Session 10 Slide 15 of 21
  • 16. Object-Oriented Programming Using C# Using Classes and Inheritance In C#, inheritance is the property by which the objects of a derived class possess copies of the data members and the member functions of the base class. A class that inherits or derives attributes from another class is called the derived class. The class from which attributes are derived is called the base class. In object-oriented programming, the base class is actually a superclass and the derived class is a subclass. Ver. 1.0 Session 10 Slide 16 of 21
  • 17. Object-Oriented Programming Using C# Implementing Inheritance Each instance of the derived class includes the attributes of the base class. Any change made to the base class automatically changes the behavior of its derived classes. The syntax used in C# for creating derived classes is as follows: <access-specifier> class <base_class> { ... } class <derived_class> : <base_class> { ... } Ver. 1.0 Session 10 Slide 17 of 21
  • 18. Object-Oriented Programming Using C# Implementing Inheritance (Contd.) You can use the following thumb rule to establish whether inheritance is required while you are designing a program. Always check the kind of relationship between the derived and the base class. Ensure that the derived class can base class. You can also use inherited classes with constructors. In inheritance, the derived class receives the base class member variables and methods. This means that an order of inheritance must be followed during the construction of an object. Ver. 1.0 Session 10 Slide 18 of 21
  • 19. Object-Oriented Programming Using C# Summary In this session, you learned that: Operators may be classified as unary and binary operators. Unary operators work with one operand and are classified as: • Simple prefix unary operators • Pre and post increment and decrement operators – A prefix unary operator may be defined by a member function that takes no parameters or by a nonmember function that takes one parameter. – Binary operators work with two operands. – Overloading a binary operator is similar to overloading a unary operator, except that a binary operator requires an additional parameter. Ver. 1.0 Session 10 Slide 19 of 21
  • 20. Object-Oriented Programming Using C# Summary (Contd.) The four kinds of relationships that exist among classes are: • Inheritance relationship • Composition relationship • Utilization relationship • Instantiation relationship – Object-oriented programming enables classes to inherit commonly used state and behavior from other classes. – Generalization means that multiple classes can inherit from the same superclass. – The composition relationship exists when one class is made up of another class. – The utilization relationship exists between two or more unrelated classes if one class uses the other. Ver. 1.0 Session 10 Slide 20 of 21
  • 21. Object-Oriented Programming Using C# Summary (Contd.) An instantiation relationship is a relationship between a class and an instance of that class. A class that inherits or derives attributes from another class is called the derived class and the class from which it is derived is called the base class. Inheritance avoids redundancy in code and enables easy maintenance of code. Constructors are called in the order of base-to-derived. Ver. 1.0 Session 10 Slide 21 of 21

Editor's Notes

  1. Students have learnt the structure of different types of dimensions and the importance of surrogate keys in Module I. In this session, students will learn to load the data into the dimension tables after the data has been transformed in the transformation phase. In addition, students will also learn to update data into these dimension tables. Students already know about different types of dimension tables. Therefore, you can start the session by recapitulating the concepts. Initiate the class by asking the following questions: 1. What are the different types of dimensions? 2. Define flat dimension. 3. What are conformed dimension? 4. Define large dimension. 5. Define small dimension. 6. What is the importance of surrogate key in a dimension table? Students will learn the loading and update strategies theoretically in this session. The demonstration to load and update the data in the dimension table will be covered in next session.
  2. Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  3. Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  4. Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  5. Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  6. Students know the importance of surrogate keys. In this session students will learn the strategy to generate the surrogate key. Give an example to explain the strategy to generate the surrogate keys by concatenating the primary key of the source table with the date stamp. For example, data from a Product table has to be loaded into the Product_Dim dimension table on Feb 09, 2006. The product_code is the primary key column in the Product table. To insert the surrogate key values before loading the data into the dimension table, you can combine the primary key value with the date on which the data has to be loaded. In this case the surrogate key value can be product_code+09022006.
  7. Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  8. Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  9. Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  10. Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  11. Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  12. Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  13. You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.
  14. You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.
  15. You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.