Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

invalid method declaration error-HELP!

843810Jul 12 2009 — edited Jul 12 2009
Hello everyone. I have been trying to write a graphics program with commands. However, it is giving me a few problems. I have already written the code but now that I am trying to put in the graphics part, it is not working. I am sure I will have many more questions, but for now can you help me fix this one. Thanks and please add additional comments if you think it can help my newb program.

The invalid method error is at the beginning with Reg.
Here is all the code.



import java.util.Scanner;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.awt.Graphics;

public class Regular
{
public static void main(String args[])
{
Regular Reg=new Regular();
}

public Reg() /////////ERROR!!!!!!!!!!!!!
{
//set background
java.awt.Graphics.setColor(Color.blue);
java.awt.Graphics.fillRect(0,0,1000,700);

int fields;
int wells;
int welnum;
int mutate=0;
ArrayList<Integer>xcor= new ArrayList<Integer>();
ArrayList<Integer>ycor= new ArrayList<Integer>();
Scanner in= new Scanner(System.in);
System.out.println("How many fields do you wish to enter?");
fields=in.nextInt();

if(fields>0)
{
for(int f=0;f<fields;f++)
{
//set page black and draw field
int x=(int)(Math.random()*950);
int y=(int)(Math.random()*650);
xcor.add(x);
ycor.add(y);
System.out.println("How many wells do you wish to drill in this field?");
wells=in.nextInt();
if(wells>0)
{
for(int w=0;w<wells;w++)
{
//set page white and draw well in location
int x1=(int)(Math.random()*30+10);
int y1=(int)(Math.random()*30+10);
}
}
}

System.out.println("Enter 123 to add another field, 456 to add a well to a desired field, or 999 to exit.");
mutate=in.nextInt();
}
else if(fields==0)
{
System.out.println("Enter 123 to add another field, 456 to add a well to a desired field, or 999 to exit.");
mutate=in.nextInt();
}

//add loop here????
for(int z=0;z<3;z++)
{
if(mutate==123)
{
System.out.println("How many fields do you wish to enter?");
fields=in.nextInt();
if(fields>0)
{
for(int f=0;f<fields;f++)
{
//set page black and draw field
int x=(int)(Math.random()*950);
int y=(int)(Math.random()*650);
xcor.add(x);
ycor.add(y);
System.out.println("How many wells do you wish to drill in this field?");
wells=in.nextInt();
if(wells>0)
{
for(int w=0;w<wells;w++)
{
//set page white and draw well in location
int x1=(int)(Math.random()*30+10);
int y1=(int)(Math.random()*30+10);
}
}
}

System.out.println("Enter 123 to add another field, 456 to add a well to a desired field, or 999 to exit.");
mutate=in.nextInt();
}
else if(fields==0)
{
System.out.println("Enter 123 to add another field, 456 to add a well to a desired field, or 999 to exit.");
mutate=in.nextInt();
}

}

else if(mutate==456)
{
System.out.println("In which field number do you wish to drill a well?");
welnum=in.nextInt();
xcor.get(welnum-1);
ycor.get(welnum-1);
System.out.println("How many wells do you wish to drill in this field?");
wells=in.nextInt();
if(wells>0)
{
for(int w=0;w<wells;w++)
{
//set page white and draw well in location relative to welnum points...xcor.get(welnum-1)+x1
int x1=(int)(Math.random()*30+10);
int y1=(int)(Math.random()*30+10);
}
}
System.out.println("Enter 123 to add another field, 456 to add a well to a desired field, or 999 to exit.");
mutate=in.nextInt();
}

else if(mutate==999)
{
z=3;
}
}




}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 9 2009
Added on Jul 12 2009
5 comments
218 views