Lecture overview -- Keyboard shortcut: 'u'  Previous page: Extension of Classes -- Keyboard shortcut: 'p'  Next page: The intension of class extensions -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 11 : 40
Object-oriented Programming in C#
Specialization, Extension, and Inheritance
An example of simple extension

We extend the 2D Point class to a 3D Point class

/user/normark/oop-csharp-1/sources/c-sharp/point/2d3d/Point.csThe class Point2D.


/user/normark/oop-csharp-1/sources/c-sharp/point/2d3d/Point3D.csThe class Point3D which extends class Point3d.


/user/normark/oop-csharp-1/sources/c-sharp/point/2d3d/Client.csA client of the classes Point2D and Point3d.


/user/normark/oop-csharp-1/sources/c-sharp/point/2d3d/outputThe output from the Client program.


Go to exercisePoint3D: A client or a subclass of Point2D?
  • Some observations:

    • A 3D point is not a 2D point

    • Thus, Point3D is not a specialization of Point2D

    • The set of 2D point objects is disjoint from the set of 3D points

The class Point2D was a convenient starting point of the class Point3D

We have reused some data and operations from class Point2D in class Point3D