English subtitles

← Polymorphism - Intro to Java Programming

Get Embed Code
6 Languages

Showing Revision 4 created 05/25/2016 by Udacity Robot.

  1. Here we have the red ball in the ball class. One has to do two things. First of
  2. all, the ball must implement the drawable interface. And we need to supply a
  3. draw method, in this case the method was very simple. It simply fills the
  4. circular shape. In the Scene class, we add a Ball, and that's it, nothing else
  5. needs to be changed. The mechanism that does the drawing stays completely the
  6. same. That's polymorphism in action. we have a general mechanism that can deal
  7. with any drawables. And if we want to add more, then we can simply add them
  8. without having to make any further changes.