Making a circle red is such a trivial difference! A red circle is really just a circle with a slightly different behaviour. In fact, RedCircle just extends the behaviour of Circle.
Making a circle red is such a trivial difference! A red circle is really just a circle with a slightly different behaviour. In fact, RedCircle just extends the behaviour of Circle.
Making a circle red is such a trivial difference! A red circle is really just a circle with a slightly different behaviour. In fact, RedCircle just extends the behaviour of Circle.
This means that RedCircle inherits all the state and behaviour of a normal circle. All that has to be defined is the difference. RedCircle is said to be a subclass of Circle. Another way of putting that is to say that Circle is the superclass of RedCircle.
This means that RedCircle inherits all the state and behaviour of a normal circle. All that has to be defined is the difference. RedCircle is said to be a subclass of Circle. Another way of putting that is to say that Circle is the superclass of RedCircle.
This means that RedCircle inherits all the state and behaviour of a normal circle. All that has to be defined is the difference. RedCircle is said to be a subclass of Circle. Another way of putting that is to say that Circle is the superclass of RedCircle.
RedCircle's draw method is said to override the draw method of Circle. It is a more specialised version of the same thing. Still, we can get even more out if inheritance because actually drawing the circle is still the same, whether coloured or not. In fact, we can ask the super class to do it for us.
RedCircle's draw method is said to override the draw method of Circle. It is a more specialised version of the same thing. Still, we can get even more out if inheritance because actually drawing the circle is still the same, whether coloured or not. In fact, we can ask the super class to do it for us.
RedCircle's draw method is said to override the draw method of Circle. It is a more specialised version of the same thing. Still, we can get even more out if inheritance because actually drawing the circle is still the same, whether coloured or not. In fact, we can ask the super class to do it for us.
Finished code.
class Circle {
}
class Circle {
}
class RedCircle extends Circle {
}
class RedCircle extends Circle {
}
class RedCircle extends Circle {
*}
class RedCircle extends Circle {
public void draw(java.awt.Graphics g){
g.setColor(java.awt.Color.red);
g.drawOval(x, y, size, size);
}
}
class RedCircle extends Circle {
public void draw(java.awt.Graphics g){
g.setColor(java.awt.Color.red);
g.drawOval(x, y, size, size);
}
}
class RedCircle extends Circle {
public void draw(java.awt.Graphics g){
g.setColor(java.awt.Color.red);
g.drawOval(x, y, size, size);
}
}
class RedCircle extends Circle {
public void draw(java.awt.Graphics g){
g.setColor(java.awt.Color.red);
super.draw(g);
}
}
class RedCircle extends Circle {
public void draw(java.awt.Graphics g){
g.setColor(java.awt.Color.red);
super.draw(g);
}
}