Conclusion

Here’s what you learned in this lesson:

  • Inheritance and polymorphism enable you to create flexible, reusable code.
  • You created a PublicDomainObject subclass of MuseumObject.
  • It has a property, primaryImageSmall, that isn’t in the parent class, so you added it to the primary constructor.
  • You redefined showImage(), then called this method from a MuseumObject and from a PublicDomainObject.
  • Each object behaved according to its type: The MuseumObject used WebViewComposable, and the PublicDomainObject used MuseumObjectComposable.
See forum comments
Download course materials from Github
Previous: Demo Next: Inheritance & Polymorphism Quiz