froggy007
Programmer
- Mar 8, 2008
- 1
Hey,
Have been practising writing classes and having been used to passing parameters through a methd. Now, I am faced with graphics : (
How or what can I pass through in my main for each of the parameters I have defined i.e. Graphics page, int x, int y, int rad, Color color. Obviosuly I know that x, y and rad are intergers but not sure what to pass thru for a graphics page and how to pass thru a color??
Also, I have deliberatley not put a return type in my method but with my new instance in main I am not sure what type to use for the new circle object??
Code:
package Chapter4;
import java.awt.*;
// assumes java.awt.* is imported
public class DrawCircle{
public DrawCircle(){
}
public DrawCircle (Graphics page, int x, int y, int rad, Color color)
{
page.setColor(color);
page.drawOval(x, y, rad, rad);
}
public static void main(String[]args){
DrawCircle circle = new DrawCircle();
newcircle = circle.drawcircle(4,4,4,blue);?????
}
}
Have been practising writing classes and having been used to passing parameters through a methd. Now, I am faced with graphics : (
How or what can I pass through in my main for each of the parameters I have defined i.e. Graphics page, int x, int y, int rad, Color color. Obviosuly I know that x, y and rad are intergers but not sure what to pass thru for a graphics page and how to pass thru a color??
Also, I have deliberatley not put a return type in my method but with my new instance in main I am not sure what type to use for the new circle object??
Code:
package Chapter4;
import java.awt.*;
// assumes java.awt.* is imported
public class DrawCircle{
public DrawCircle(){
}
public DrawCircle (Graphics page, int x, int y, int rad, Color color)
{
page.setColor(color);
page.drawOval(x, y, rad, rad);
}
public static void main(String[]args){
DrawCircle circle = new DrawCircle();
newcircle = circle.drawcircle(4,4,4,blue);?????
}
}