RedCircle Class

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.

RedCircle Class

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.

RedCircle Class

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.

RedCircle Class

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 Class

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 Class

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 Class

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 Class

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 Class

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 Class

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);
	}

}