This site requires JavaScript, please enable it in your browser!
Greenfoot back
JayWood860
JayWood860 wrote ...

2012/9/22

Project Failed To Compile

JayWood860 JayWood860

2012/9/22

#
When I compile individual classes in my greenfoot project, there are no syntax errors. However, when I compile it using the button below the class diagrams, the classes compile but my world wouldn't appear (I still have the super method). I was curious as to whether this was because I exceeded a memory cap that greenfoot gives to its projects. If not, why is this?
danpost danpost

2012/9/22

#
What does the beginning of your world class code look like? I would like to see any code related to the construction of the world. That is, the world class from start to the end of the constructor, plus any methods that the constructor calls.
JayWood860 JayWood860

2012/9/23

#
Here is the code. Let me know if i should show more methods for the world class
public class Court extends World
{
    static Me me = new Me();
    static CP cp = new CP("F"); DW dw = new DW("O");
    static KD kd = new KD("I"); LBJ lbj = new LBJ("L");
    
    
    static Ball b = me.ball;
    static Problem p, p1, p2, p3, p4, pF;
    static ArrayList<Integer> vars, cons;
    static String quantity1, quantity2, quantity3, quantity4, theFinal;
    static int one, two, alpha, beta, key = 1;
    static boolean go = false, probDisplayed = false, ready = false;
    /**
     * Constructor for objects of class Court.
     * 
     */
    public Court()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(656, 553,1); 
        set();
        
        Greenfoot.start();
        displayProblem();
    }
    public void displayProblem(){
        organize();
        one = vars.get(r()); two = vars.get(r()); 
        alpha = cons.get(r()); beta = cons.get(r());
        quantity1 = "(" + one + "x" + " + " + two + ")";
        quantity2 = "(" + alpha + "x" + " + " + beta + ")";
        p = new Problem(quantity1+quantity2, Font.BOLD);
        addObject(p, getWidth()/2, getHeight()/2);
    }
    public void organize(){
        vars = new ArrayList<Integer>(); cons = new ArrayList<Integer>();
        int i = 0;
        while (i < 1000){
            vars.add(i);
            i++;
        }
        int x = 0;
        while (x <= 1000){
            cons.add(x);
            x++;
        }
    }
Builderboy2005 Builderboy2005

2012/9/23

#
This is most likely coming from an infinite loop in the constructor of either the world or an object the world is creating. Take a look through your code and see if any piece looks like it might be causing an infinite loop. Additionally, you can place System.out.println() statements all around to see just how far your code is getting before it freezes, and you can narrow down the range with that.
danpost danpost

2012/9/23

#
I do see the method 'set()', nor 'r()', anywhere here. Nor do I see the constructors for 'Me', 'CP', 'DW', 'KD', 'LBJ', or 'Problem'; all of which are being called during construction of the world.
You need to login to post a reply.