title: Polymorphism With Ovals
body: <h2>If you were given a class called BouncyFace that had the following code:</h2>
  
  <pre><code>    import javax.swing.*;
      import java.awt.*;
      public class BouncyFace extends JComponent  {
          protected int xDelta = 1;
          protected int yDelta = 1;
          private Color fleshColor;
          public BouncyFace(int x, int y, int side)  {
          super();
          setBounds(x, y, side, side);
          fleshColor = new Color(214,157,106);
          setBackground(fleshColor);
          setForeground(Color.black);
      }
  
  
        public void paint(Graphics g)  {
          g.setColor( getBackground() );
          g.fillOval(0, 0, getWidth()-1, getHeight()-1);
     }
  
      public void move() {
         if (getParent() != null) {
         setLocation( getX()+xDelta, getY()+yDelta );
         if ((xDelta &gt; 0) &amp;&amp; (getX()+getWidth() &gt; getParent().getWidth()) ) {
             xDelta = -Math.abs(xDelta);
         } else if ((xDelta &lt; 0) &amp;&amp; (getX() &lt; 0)) {
             xDelta = Math.abs(xDelta);
         }
         if ((yDelta &gt; 0) &amp;&amp; (getY()+getHeight() &gt; getParent().getHeight()) ) {
             yDelta = -Math.abs(yDelta);
         } else if ((yDelta &lt; 0) &amp;&amp; (getY() &lt; 0)) {
             yDelta = Math.abs(yDelta);
         }           
         repaint();
     }
  </code></pre>
  
  <p>And you were told to create a class that alters paint() so that BouncyFace draws not just an oval, but also two small ovals in it, how would you go about doing this?</p>
  
  <p>Edit:</p>
  
  <p>Ok, So Here is the new class I have-</p>
  
  <pre><code>    import javax.swing.*;
      import java.awt.*;
      public class Features extends BouncyFace
      {
        public Features(int x,int y, int side)
       {
          super(x,y,side);
          //setBounds(x,y,side,side);
      }
  
  
       public void paint(Graphics g)
       {
         super.paint(g);
         //g.setColor( getBackground() );
         g.drawOval(10, 10, getWidth(), getHeight());
  
       }
    }
  </code></pre>
  
  <p>However, I believe this overrode the old paint because it only shows me the new oval when I do this in the Driver</p>
  
  <p>private Features eyes;</p>
  
  <p>eyes = new Features(10,10,10);</p>
  
  <p>Does this have to do with the paramters that I set? Sorry for asking so much, I am just trying to understand inheritence with polymorphism and I am completely stuck here and think its unnecessary to start a new question.</p>
  
  <p>Thank you for all your insight on this problem. I have solved it and now working on another problem. Thank you stackoverflow community.</p>