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?
OO Pong - need help designing
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Jaish MathewsRank #225 · 11K reputationPosted Mar 26, 2010, 11:03 PM EDT
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
{
}