Diagram Desk

Animal polymorphism class diagram

Dog and cat inherit from animal and implement speak differently: the standard picture for polymorphism.

The diagram

Animal«abstract»#name String+speak() StringDog+speak() String+walk() voidCat+speak() String
Class diagram · 8 shapes

Reading it step by step

  • 'Animal' (abstract class): 1 attributes, 1 methods.
  • 'Dog' (class): 0 attributes, 2 methods.
  • 'Cat' (class): 0 attributes, 1 methods.
  • 'Dog' inherits from 'Animal'.
  • 'Cat' inherits from 'Animal'.

Shape by shape

ShapeSymbolConnections
Animalabstractholds #name String, +speak() String · ← Dog, Cat
DogClassholds +speak() String, +walk() void · → Animal
CatClassholds +speak() String · → Animal

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.

# Animal polymorphism class diagram
classDiagram
  class Animal {
    <<abstract>>
    #name String
    +speak() String
  }
  class Dog {
    +speak() String
    +walk() void
  }
  class Cat {
    +speak() String
  }
  Animal <|-- Dog
  Animal <|-- Cat

More class diagram examples

All SeewolLabs tools