
Please I need help solving this Oval and FilledOval code by changing the instance variables in Oval that are in public, which is not optimal, to private and re-implement any code that depended on the public accessibility of those instance variables. Here is the code:
import java.awt.*;
public class Oval { public int x, y, w, h;
public Oval(int x, int y, int w, int h) {
this.x = x; this.y = y; this.w = w; this.h = h;
}
public void draw(Graphics g) {
g.drawOval(x,y,w,h;
}
public int getWidth() { return w; }
public int getHeight() { return h; }
public Point getTopLeftPoint() { return new Point(x,y); }
//...other methods...
}
public class FilledOval extends Oval { public FilledOval(int x, int y, int w, int h) { super(x, y, w, h); }
public void draw(Graphics g)
{
g.fillOval(x, y, w, h);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.