hi Folks.
Been a loong time since I had to do any OO programming so letting myself back into it gently by trying to write an object oriented version of pong.
I have a Toy class. Ball and Paddle will be sub classes(inherit) the toy class.
I need to implement a draw method. As a paddle is very different from a ball, im wondering if i should have the draw method in the Toy class at all.
Should the draw method be specified in an interface, forcing the ball and paddle to implement their own draw methods?
Loading
Jaish MathewsPosted Mar 27, 2010, 3:03 AM
Not exactly. Scenario is like this.
So design should be some thing like this. I used abstract class for that parent, as we have the flexibility of default implementation in side it.
public interface IToy
{
}
public interface IBall
{
}
public interface IPaddle
{
}
public abstract class Toy : IToy
{
//Define default draw logic.
}
public class Ball : Toy, IBall
{
}
public class Paddle : Toy, IPaddle
{
}