Nenad
~Choco Coronet~ Omnomnom
- Reaction score
- 137
Been a while since i asked for help (mostly cause I was doing well), but now I've run into a problem.
This is what I'm supposed to do:
As you may have noticed I need to use an extension program called ACM, of which the libraries are found here: Link..
That being said I'm having a serious problem with making the constructor. I just don't understand how to make a constructor that works such as:
public GCircle(double x)
{
??? GOval(x,x)
}
profit.
I need to use the GOval class (at least i believe so) because i need to draw a circle, and it will draw a circle when i use the class, but i can't get it to work. This class is invoked from another class, GSpriteProgram, which is basically this:
I've already written the sprite code and that code works properly, but this code does not create a circle because i lack the proper constructor. Therefore i'm stumped, if you need any more information ask me so i can get passed this issue.
This is what I'm supposed to do:
Write a class called GCircle (public class GCircle extends GObject implements ...)
The purpose of this class is to easily be able to draw circles.
GCircle must have the following methods:
GCircle(double) [constructor]
getRadius()
setRadius(double)
In addition, GCircle must implement necessary methods from the superclass and implemented interfaces. You must decide which of the interfaces GScalable, GFillable and GResizable it makes sense to implement, and hence which additional methods that must be implemented.
As you may have noticed I need to use an extension program called ACM, of which the libraries are found here: Link..
That being said I'm having a serious problem with making the constructor. I just don't understand how to make a constructor that works such as:
public GCircle(double x)
{
??? GOval(x,x)
}
profit.
I need to use the GOval class (at least i believe so) because i need to draw a circle, and it will draw a circle when i use the class, but i can't get it to work. This class is invoked from another class, GSpriteProgram, which is basically this:
Code:
import acm.graphics.GCanvas;
import acm.program.GraphicsProgram;
public class GSpriteProgram extends GraphicsProgram {
public void run() {
GCircle circle = new GCircle(20.0);
circle.setLocation(50, 20);
GSprite sprite = new GBouncingObject("workspace/sprite1.png");
sprite.setSpeed(20, 30);
add(circle);
add(sprite);
}
}
I've already written the sprite code and that code works properly, but this code does not create a circle because i lack the proper constructor. Therefore i'm stumped, if you need any more information ask me so i can get passed this issue.