.. This file is part of the OpenDSA eTextbook project. See
.. http://opendsa.org for more details.
.. Copyright (c) 2012-2020 by the OpenDSA Project Contributors, and
.. distributed under an MIT open source license.

.. avmetadata::
   :author: Molly Domino


More on Polymorphism
====================

Objectives
----------

* Review Java Interfaces and Abstract Classes
* Review Inheritance and Composition
* Review Overloading and Overriding
* Review Reference Variables
* Apply Typecasting

Interactive: Polymorphism Measurable Interface [7:23]
-----------------------------------------------------

Polymorphism Example Code
~~~~~~~~~~~~~~~~~~~~~~~~~
.. admonition:: Try It Yourself

   In Eclipse, use the *Project > Download Assignment...* menu command to download the exercise project named "ex07.04-MeasurableInterface". Use this example to follow along with the following video. Feel free to experiment. 
   
   Refer to `01.02: Lab: LightBot for Beginners <https://profdev-lms.tlos.vt.edu/courses/2832/assignments/10634>`_ if you need to review the instructions for downloading Eclipse projects.
   
   .. raw:: html
   
      <a href="https://courses.cs.vt.edu/~cs2114/meng-bridge/course-notes/7.4.1.1-JavaOOPPolyMeasurable.pdf" target="_blank">
      <img src="https://courses.cs.vt.edu/~cs2114/meng-bridge/images/projector-screen.png" alt="" width="32" height="32">
      Video Slides 7.4.2.1-JavaOOPPolyMeasurable.pdf</img>
      </a>


.. raw:: html

   <div style="position: relative; width: 100%; height: 0; padding-bottom: 38%">
     <iframe src="https://virginiatech.hosted.panopto.com/Panopto/Pages/Embed.aspx?id=ac8afca7-325c-48a0-a203-b401011f0aa4&autoplay=false&offerviewer=true&showtitle=true&showbrand=true&captions=false&interactivity=all" style="border: 1px solid #464646; position: absolute; top: 0; left: 0; width: 960px; height: 395px; box-sizing: border-box;" allowfullscreen allow="autoplay" aria-label="Polymorphism Example" aria-description="Polymorphism Example"></iframe>
  </div>

Checkpoint 1
------------

.. avembed:: Exercises/MengBridgeCourse/OOP2Checkpoint1Summ.html ka
   :long_name: Checkpoint 1


Programming Practice: Polymorphism 1
------------------------------------

.. extrtoolembed:: 'Programming Practice: Polymorphism 1'
   :workout_id: 1907

.. _IntroPolySuper: 

Interactive: Polymorphism Computer Superclass [12:09]
-----------------------------------------------------

.. admonition:: Follow Along and Engage

    Download the slides corresponding to the video. Take notes on them as you watch the video, practice drawing diagrams yourself!

   .. raw:: html
   
      <a href="https://courses.cs.vt.edu/~cs2114/meng-bridge/course-notes/7.4.4.1-JavaOOPPolyComputer.pdf" target="_blank">
         <img src="https://courses.cs.vt.edu/~cs2114/meng-bridge/images/projector-screen.png" alt="" width="32" height="32">
         Video Slides 7.4.5-JavaOOPPolyComputer.pdf</img>
         </a>


.. raw:: html

   <div style="position: relative; width: 100%; height: 0; padding-bottom: 38%">
     <iframe src="https://virginiatech.hosted.panopto.com/Panopto/Pages/Embed.aspx?id=b79c21f1-928d-4c9b-8b84-b40c0076a902&autoplay=false&offerviewer=true&showtitle=true&showbrand=true&captions=false&interactivity=all" style="border: 1px solid #464646; position: absolute; top: 0; left: 0; width: 960px; height: 395px; box-sizing: border-box;" allowfullscreen allow="autoplay" aria-label="Polymorphism Computer Superclass" aria-description="Polymorphism Computer Superclass"></iframe>
  </div>
  
Checkpoint 2
------------

.. avembed:: Exercises/MengBridgeCourse/OOP2Checkpoint2Summ.html ka
   :long_name: Checkpoint 2



Interactive: Polymorphism Integer Example [7:40]
------------------------------------------------

.. admonition:: Follow Along and Engage

    Download the slides corresponding to the video. Take notes on them as you watch the video, practice drawing diagrams yourself!

   .. raw:: html
      
         <a href="https://courses.cs.vt.edu/~cs2114/meng-bridge/course-notes/7.6.4.1-JavaOOPPolyInteger.pdf" target="_blank">
         <img src="https://courses.cs.vt.edu/~cs2114/meng-bridge/images/projector-screen.png" alt="" width="32" height="32">
         Video Slides 7.6.7-JavaOOPPolyInteger.pdf</img>
         </a>

.. raw:: html

   <div style="position: relative; width: 100%; height: 0; padding-bottom: 38%">
     <iframe src="https://virginiatech.hosted.panopto.com/Panopto/Pages/Embed.aspx?id=042015a4-4cc0-4077-9d1f-b41d004c5c37&autoplay=false&offerviewer=true&showtitle=true&showbrand=true&captions=false&interactivity=all" style="border: 1px solid #464646; position: absolute; top: 0; left: 0; width: 960px; height: 395px; box-sizing: border-box;" allowfullscreen allow="autoplay" aria-label="Polymorphism Integer Example" aria-description="Polymorphism Integer Example"></iframe>
  </div>

Checkpoint 3
------------

.. avembed:: Exercises/MengBridgeCourse/OOP2Checkpoint3Summ.html ka
   :long_name: Checkpoint 3


Programming Practice: Polymorphism 2
------------------------------------

.. extrtoolembed:: 'Programming Practice: Polymorphism 2'
   :workout_id: 1908


