SlideShare a Scribd company logo
Example In C#
Shows How Object Oriented
            Is


  Classes/Polymorphesim
Inherentence/Overloading
       & Overriding




       Done By:-
  MARWA SAMIH AL-AMRI
using System;
using System.Collections.Generic;
using System.Text;

namespace uml
{
    class Shape
    {
        public virtual void draw()
        {
            Console.WriteLine("Empty");
        }
    }
{



using System;
using System.Collections.Generic;
using System.Text;

namespace uml
{
    class Circle:Shape
    {
        public override void draw()
        {
            Console.WriteLine("This is Circle");
        }

        public double m (int x,int y)
        {
            return x * y;
        }

        public double m(int x, double y, int z)
        {
            Console.WriteLine("nnthe integer version = "+ m(1,2));
            Console.WriteLine("the double version = " + m(2.3 , 2));
            Console.WriteLine("with different order = " + m(2, 2.3));
            return x * y / z;
        }

        public double m(double x, int y)
        {
            return x * y;
        }

        public double m(int x, double y)
        {
            return x / y;
        }



    }
}
using System;
using System.Collections.Generic;
using System.Text;

namespace uml
{
    class Rectangle:Shape
    {
        public override void draw()
        {
            Console.WriteLine("This is Rectangle");
        }
    }
}




using System;
using System.Collections.Generic;
using System.Text;

namespace uml
{
    class Square:Rectangle
    {
        public override void draw()
        {
            base.draw();
            Console.WriteLine("this is Square");
        }

    }
}




using System;
using System.Collections.Generic;
using System.Text;

namespace uml
{
    class Program
    {
        static void Main(string[] args)
        {
            Shape S;
            Rectangle R = new Rectangle();

           S = R;
           S.draw();

           S = new Circle();
S.draw();
             //S.printCenter();      error

             Circle C = new Circle();
             C.printCenter();

             S = new Square();
             S.draw();

             R = new Square();
             S = R;
             S.draw();

             //R = S; error
             Console.WriteLine("n");

            Shape   [] sh    = new Shape[4];
            sh[3]   = new   Shape();
            sh[0]   = new   Rectangle();
            sh[1]   = new   Circle();
            sh[2]   = new   Square();

            for (int i = 0; i < 4; i++)
                sh[i].draw();

        }
    }
}

More Related Content

What's hot

Graph Plots in Matlab
Graph Plots in MatlabGraph Plots in Matlab
Graph Plots in Matlab
DataminingTools Inc
 
Day 2 examples u2f13
Day 2 examples u2f13Day 2 examples u2f13
Day 2 examples u2f13
jchartiersjsd
 
Day 9 examples u1w14
Day 9 examples u1w14Day 9 examples u1w14
Day 9 examples u1w14
jchartiersjsd
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
ritu1806
 
week-11x
week-11xweek-11x
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
Dr. Loganathan R
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
Dr. Loganathan R
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
pramodkumar1804
 
week-4x
week-4xweek-4x
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
Yoshiki Satotani
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Javascript Array map method
Javascript Array map methodJavascript Array map method
Javascript Array map method
tanerochris
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
Geunhyung Kim
 
กลุ่ม6
กลุ่ม6กลุ่ม6
กลุ่ม6
Witita Khamsook
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
Divya Kumari
 
C programs
C programsC programs
C programs
Bharathi N Reddy
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
shahid sultan
 
2.5 function transformations
2.5 function transformations2.5 function transformations
2.5 function transformations
hisema01
 
2.6 transformations
2.6 transformations2.6 transformations
2.6 transformations
hisema01
 
5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment 5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment
pcnmtutorials
 

What's hot (20)

Graph Plots in Matlab
Graph Plots in MatlabGraph Plots in Matlab
Graph Plots in Matlab
 
Day 2 examples u2f13
Day 2 examples u2f13Day 2 examples u2f13
Day 2 examples u2f13
 
Day 9 examples u1w14
Day 9 examples u1w14Day 9 examples u1w14
Day 9 examples u1w14
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
week-11x
week-11xweek-11x
week-11x
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
week-4x
week-4xweek-4x
week-4x
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
 
Javascript Array map method
Javascript Array map methodJavascript Array map method
Javascript Array map method
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
 
กลุ่ม6
กลุ่ม6กลุ่ม6
กลุ่ม6
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
 
C programs
C programsC programs
C programs
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
2.5 function transformations
2.5 function transformations2.5 function transformations
2.5 function transformations
 
2.6 transformations
2.6 transformations2.6 transformations
2.6 transformations
 
5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment 5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment
 

Viewers also liked

Oracle qs
Oracle qsOracle qs
example of OMT TECHNIQUE (UML)
example of OMT TECHNIQUE (UML)example of OMT TECHNIQUE (UML)
example of OMT TECHNIQUE (UML)
MaRwa Samih AL-Amri
 
SRS Document Of Course management software system.doc
SRS Document Of Course management software system.docSRS Document Of Course management software system.doc
SRS Document Of Course management software system.doc
MaRwa Samih AL-Amri
 
Oracle examples
Oracle examplesOracle examples
Oracle examples
MaRwa Samih AL-Amri
 
100 PHP question and answer
100 PHP  question and answer100 PHP  question and answer
100 PHP question and answer
Sandip Murari
 
Classes and Objects In C# With Example
Classes and Objects In C# With ExampleClasses and Objects In C# With Example
Classes and Objects In C# With Example
Cheezy Code
 
C# and Dot Net by Example
C# and Dot Net by ExampleC# and Dot Net by Example
C# and Dot Net by Example
Ganesh Karthik
 
Android OS
Android OSAndroid OS
Android OS
Ravi Yasas
 
Beer vs wine by Sandip Murari
Beer vs wine by Sandip MurariBeer vs wine by Sandip Murari
Beer vs wine by Sandip Murari
Sandip Murari
 
Modern Management Thoughts
Modern Management ThoughtsModern Management Thoughts
Modern Management Thoughts
Ravi Yasas
 
Proposal: A Study on Business Communucation System of KAZ Software
Proposal: A Study on Business Communucation System of KAZ SoftwareProposal: A Study on Business Communucation System of KAZ Software
Proposal: A Study on Business Communucation System of KAZ Software
Minhas Kamal
 
Software Project Management: Release Notes
Software Project Management: Release NotesSoftware Project Management: Release Notes
Software Project Management: Release Notes
Minhas Kamal
 
Software Project Management: Configuration Management
Software Project Management: Configuration ManagementSoftware Project Management: Configuration Management
Software Project Management: Configuration Management
Minhas Kamal
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
Intro C# Book
 
Software Requirements Specification on Bengali Braille to Text Translator
Software Requirements Specification on Bengali Braille to Text TranslatorSoftware Requirements Specification on Bengali Braille to Text Translator
Software Requirements Specification on Bengali Braille to Text Translator
Minhas Kamal
 
Software Project Management: Testing Document
Software Project Management: Testing DocumentSoftware Project Management: Testing Document
Software Project Management: Testing Document
Minhas Kamal
 
A pattern based approach to the development of updm architectures
A pattern based approach to the development of updm architecturesA pattern based approach to the development of updm architectures
A pattern based approach to the development of updm architectures
Graham Bleakley
 
Project Proposal: Bengali Braille to Text Translation
Project Proposal: Bengali Braille to Text TranslationProject Proposal: Bengali Braille to Text Translation
Project Proposal: Bengali Braille to Text Translation
Minhas Kamal
 
Software Project Management: Project Planning
Software Project Management: Project PlanningSoftware Project Management: Project Planning
Software Project Management: Project Planning
Minhas Kamal
 
Software Project Management: Change Control
Software Project Management: Change ControlSoftware Project Management: Change Control
Software Project Management: Change Control
Minhas Kamal
 

Viewers also liked (20)

Oracle qs
Oracle qsOracle qs
Oracle qs
 
example of OMT TECHNIQUE (UML)
example of OMT TECHNIQUE (UML)example of OMT TECHNIQUE (UML)
example of OMT TECHNIQUE (UML)
 
SRS Document Of Course management software system.doc
SRS Document Of Course management software system.docSRS Document Of Course management software system.doc
SRS Document Of Course management software system.doc
 
Oracle examples
Oracle examplesOracle examples
Oracle examples
 
100 PHP question and answer
100 PHP  question and answer100 PHP  question and answer
100 PHP question and answer
 
Classes and Objects In C# With Example
Classes and Objects In C# With ExampleClasses and Objects In C# With Example
Classes and Objects In C# With Example
 
C# and Dot Net by Example
C# and Dot Net by ExampleC# and Dot Net by Example
C# and Dot Net by Example
 
Android OS
Android OSAndroid OS
Android OS
 
Beer vs wine by Sandip Murari
Beer vs wine by Sandip MurariBeer vs wine by Sandip Murari
Beer vs wine by Sandip Murari
 
Modern Management Thoughts
Modern Management ThoughtsModern Management Thoughts
Modern Management Thoughts
 
Proposal: A Study on Business Communucation System of KAZ Software
Proposal: A Study on Business Communucation System of KAZ SoftwareProposal: A Study on Business Communucation System of KAZ Software
Proposal: A Study on Business Communucation System of KAZ Software
 
Software Project Management: Release Notes
Software Project Management: Release NotesSoftware Project Management: Release Notes
Software Project Management: Release Notes
 
Software Project Management: Configuration Management
Software Project Management: Configuration ManagementSoftware Project Management: Configuration Management
Software Project Management: Configuration Management
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
 
Software Requirements Specification on Bengali Braille to Text Translator
Software Requirements Specification on Bengali Braille to Text TranslatorSoftware Requirements Specification on Bengali Braille to Text Translator
Software Requirements Specification on Bengali Braille to Text Translator
 
Software Project Management: Testing Document
Software Project Management: Testing DocumentSoftware Project Management: Testing Document
Software Project Management: Testing Document
 
A pattern based approach to the development of updm architectures
A pattern based approach to the development of updm architecturesA pattern based approach to the development of updm architectures
A pattern based approach to the development of updm architectures
 
Project Proposal: Bengali Braille to Text Translation
Project Proposal: Bengali Braille to Text TranslationProject Proposal: Bengali Braille to Text Translation
Project Proposal: Bengali Braille to Text Translation
 
Software Project Management: Project Planning
Software Project Management: Project PlanningSoftware Project Management: Project Planning
Software Project Management: Project Planning
 
Software Project Management: Change Control
Software Project Management: Change ControlSoftware Project Management: Change Control
Software Project Management: Change Control
 

Similar to C# example (Polymorphesim)

Class program and uml in c++
Class program and uml in c++Class program and uml in c++
Class program and uml in c++
Osama Al-Mohaia
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
LearningTech
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
LearningTech
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
LearningTech
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
aromanets
 
C#
C#C#
C# I need assitance on my code.. Im getting an error message Us.pdf
C# I need assitance on my code.. Im getting an error message Us.pdfC# I need assitance on my code.. Im getting an error message Us.pdf
C# I need assitance on my code.. Im getting an error message Us.pdf
eyezoneamritsar
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
Srinivasa Babji Josyula
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
Srinivasa Babji Josyula
 
Object Oriented Programming Using C++: C++ Namespaces.pptx
Object Oriented Programming Using C++: C++ Namespaces.pptxObject Oriented Programming Using C++: C++ Namespaces.pptx
Object Oriented Programming Using C++: C++ Namespaces.pptx
RashidFaridChishti
 
Modify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdfModify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdf
hullibergerr25980
 
Need to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdfNeed to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdf
archgeetsenterprises
 
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdfCircle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
ANJALIENTERPRISES1
 
Hi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdfHi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdf
aniyathikitchen
 
Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
Shahriar Robbani
 
C#.net
C#.netC#.net
C#.net
vnboghani
 
Dotnet unit 4
Dotnet unit 4Dotnet unit 4
Dotnet unit 4
007laksh
 
P2
P2P2
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
Sunil OS
 
I am trying to create a program That works with two other programs i.pdf
I am trying to create a program That works with two other programs i.pdfI am trying to create a program That works with two other programs i.pdf
I am trying to create a program That works with two other programs i.pdf
fortmdu
 

Similar to C# example (Polymorphesim) (20)

Class program and uml in c++
Class program and uml in c++Class program and uml in c++
Class program and uml in c++
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
 
C#
C#C#
C#
 
C# I need assitance on my code.. Im getting an error message Us.pdf
C# I need assitance on my code.. Im getting an error message Us.pdfC# I need assitance on my code.. Im getting an error message Us.pdf
C# I need assitance on my code.. Im getting an error message Us.pdf
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
Object Oriented Programming Using C++: C++ Namespaces.pptx
Object Oriented Programming Using C++: C++ Namespaces.pptxObject Oriented Programming Using C++: C++ Namespaces.pptx
Object Oriented Programming Using C++: C++ Namespaces.pptx
 
Modify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdfModify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdf
 
Need to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdfNeed to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdf
 
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdfCircle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
 
Hi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdfHi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdf
 
Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
 
C#.net
C#.netC#.net
C#.net
 
Dotnet unit 4
Dotnet unit 4Dotnet unit 4
Dotnet unit 4
 
P2
P2P2
P2
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
I am trying to create a program That works with two other programs i.pdf
I am trying to create a program That works with two other programs i.pdfI am trying to create a program That works with two other programs i.pdf
I am trying to create a program That works with two other programs i.pdf
 

C# example (Polymorphesim)

  • 1. Example In C# Shows How Object Oriented Is Classes/Polymorphesim Inherentence/Overloading & Overriding Done By:- MARWA SAMIH AL-AMRI
  • 2. using System; using System.Collections.Generic; using System.Text; namespace uml { class Shape { public virtual void draw() { Console.WriteLine("Empty"); } } { using System; using System.Collections.Generic; using System.Text; namespace uml { class Circle:Shape { public override void draw() { Console.WriteLine("This is Circle"); } public double m (int x,int y) { return x * y; } public double m(int x, double y, int z) { Console.WriteLine("nnthe integer version = "+ m(1,2)); Console.WriteLine("the double version = " + m(2.3 , 2)); Console.WriteLine("with different order = " + m(2, 2.3)); return x * y / z; } public double m(double x, int y) { return x * y; } public double m(int x, double y) { return x / y; } } }
  • 3. using System; using System.Collections.Generic; using System.Text; namespace uml { class Rectangle:Shape { public override void draw() { Console.WriteLine("This is Rectangle"); } } } using System; using System.Collections.Generic; using System.Text; namespace uml { class Square:Rectangle { public override void draw() { base.draw(); Console.WriteLine("this is Square"); } } } using System; using System.Collections.Generic; using System.Text; namespace uml { class Program { static void Main(string[] args) { Shape S; Rectangle R = new Rectangle(); S = R; S.draw(); S = new Circle();
  • 4. S.draw(); //S.printCenter(); error Circle C = new Circle(); C.printCenter(); S = new Square(); S.draw(); R = new Square(); S = R; S.draw(); //R = S; error Console.WriteLine("n"); Shape [] sh = new Shape[4]; sh[3] = new Shape(); sh[0] = new Rectangle(); sh[1] = new Circle(); sh[2] = new Square(); for (int i = 0; i < 4; i++) sh[i].draw(); } } }