Diagram Desk

Shape inheritance class diagram

Circle and rectangle inherit from an abstract shape, the first inheritance example most classes use. Each child redefines the area method.

The diagram

Shape«abstract»+color String+area() doubleCircle+radius double+area() doubleRectangle+width double+height double+area() double
Class diagram · 10 shapes

Reading it step by step

  • 'Shape' (abstract class): 1 attributes, 1 methods.
  • 'Circle' (class): 1 attributes, 1 methods.
  • 'Rectangle' (class): 2 attributes, 1 methods.
  • 'Circle' inherits from 'Shape'.
  • 'Rectangle' inherits from 'Shape'.

Shape by shape

ShapeSymbolConnections
Shapeabstractholds +color String, +area() double · ← Circle, Rectangle
CircleClassholds +radius double, +area() double · → Shape
RectangleClassholds +width double, +height double, +area() double · → Shape

Symbols used here

SymbolMeaning
ClassA box with name, attributes and methods.
InheritanceSolid line from child to parent, hollow triangle at the parent.

All class diagram symbols and how to draw

Diagram text

Paste this text into the editor to get the same picture, then change the names to fit your own work.

# Shape inheritance class diagram
classDiagram
  class Shape {
    <<abstract>>
    +color String
    +area() double
  }
  class Circle {
    +radius double
    +area() double
  }
  class Rectangle {
    +width double
    +height double
    +area() double
  }
  Shape <|-- Circle
  Shape <|-- Rectangle

More class diagram examples

All SeewolLabs tools