style on calling child method
i'm making a 'paint' application. and i want be able to draw many different shapes (rects, ovals, stars, etc)
i have a base class called ShapeTool which contains a lot of functionality for handling mouse events, calculating x, y, width, height etc.
all the instanciated tools (RectTool, OvalTool etc) inherit from ShapeTool and only contain a method draw() to draw themselves.
this draw method is called from parent class (ShapeTool) which of course needs a reference to the child
my question is if i should have :
(A) protected x, y, width, height, Graphics g fields in ShapeTool so the child's draw implementation will be like
public draw(){
g.drawOval(x, y, width, height);
}
because the child will be able to see the protected fields
or
(B) have the fields private and pass them as parameters from the ShapeTool so the child's draw implementation will be like
public draw(int x, int y, int width, int height, Graphics g){
g.drawOval(x, y, width, height);
}
tnx

