MouseGordon
MouseGordon

Reputation: 21

Uncompilable source code - Erroneous tree type error and cannot find symbol error

I was getting "Uncompilable source code - Erroneous tree type" error and "cannot find symbol" error I turned off compile on save and now get cannot find symbol. The area that seems to be breaking it is where I initialize Asteroid() in AsteroidFields generate method, so I feel like my initialization is incorrect but I haven't been able to figure out how.

package asteroidfield;
import java.util.TreeSet;
import blobzx.BlobGUI;
import blobzx.SandBox;
import blobzx.SandBoxMode;



public class AsteroidField implements BlobGUI {

    SandBox ast;

    public static void main (String [] Args){
        new AsteroidField();       
    }

    public AsteroidField (){
        ast = new SandBox();

        ast.setSandBoxMode(SandBoxMode.FLOW);   
        ast.setFrameRate(15);
        ast.init(this);

    }

    @Override
    public void generate() {
       // This is the line that is breaking the code.   
         Asteroid asteroid = new Asteroid();

    }

}








    package AsteroidField;

    import blobzx.BlobUtils;
    import blobzx.PolyBlob;
    import java.awt.Point;


    import java.util.Random;


    public class Asteroid extends PolyBlob{

    // private static Random random = new Random();

    public Asteroid(int velX, int velY, double rot) {

       super(-100, -100, rot);

       setDelta(velX, velY);

       Random sides = new Random();
       Random dist = new Random();
       int si = sides.nextInt(9 - 5 + 1) + 5;

       int di =  dist.nextInt(15 - 5 + 1) + 5;

       double region = (2 * Math.PI) / si;                 
       double []angle = new double [si];

       int [] xInt = new int[si];
       int [] yInt = new int[si];
       double [] x = new double [si];
       double [] y = new double [si];
       System.out.print("m");



       for(int i = 0; i < si; i++){


        angle[i] = (i*region)+(Math.random()*region);        
        Point cord = BlobUtils.rotatePoint(di, angle[i]);

        x[i] = cord.getX();
        y[i] = cord.getY();
       }
       for (int i = 0; i > x.length; i ++){
        xInt[i] = (int) x[i];
        yInt[i] = (int) y[i];
       }


       setPolygon(xInt, yInt);


       }
      }

Upvotes: 0

Views: 34447

Answers (3)

Your source package name and all the package names in the whole project must be written in the same way, for example if your source package name is weather, starting with small letter, but you use Weather with capital letter in a file of your project, this error will occur.

Package name is always at the first line of each file, so match it with its source package name. Source package is where we often use to create new files in our project.

Upvotes: 0

IqbalHamid
IqbalHamid

Reputation: 2532

Recheck the package declarations in all your classes!

This behaviour has been observed in NetBeans, when the package declaration in one of the classes of the package refers to a non-existent or wrong package. NetBeans normally detects and highlights this error but has been known to fail and misleadingly report the package as free of errors when this is not the case.

Upvotes: 5

Slava Vedenin
Slava Vedenin

Reputation: 60164

I see two problems:

1) May be because, you write:

Asteroid asteroid = new Asteroid();

but Asteroid class hasn't got a default construstor (at least, I not see it in your code)

public Asteroid(int velX, int velY, double rot) {

2) Or may be because you use not same package and not use import in AsteroidField

package asteroidfield;
...
package AsteroidField;

You should or use one package or add import AsteroidField.Asteroid; in AsteroidField, I think.

Upvotes: 2

Related Questions