public void act() 
    {
        // Add your action code here.  
        if(!trainSet){
            x=(Train) getWorld().getObjects(Train.class).get(0);
            System.out.println("method trainSet() executed");
            trainSet = true;
        }
        if(x.speed == 1 ){
            moveWagon();
        }
        if(isAtEdge())
        { 
            getWorld().removeObject(this);     

        }
    }