java - What's my error? How can I fix it? -


Update: All the answers are needed to answer the question below.

This is a special type of SpiralBug so I have not seen any example on the Internet; it uses SpiralBug SpiralBug code but it has additionally, once it gets to a range of BoundGrid and can not proceed now, to start again in the center of the grid, this is the place Where my problems start here is my code here is no error

spiralbuger And my code

  Import info.gridworld.actor.ActorWorld; Import info.gridworld.grid.Location; Import java.awt.color; Public category spiralbugner (public static zero main) (string agre []) (ActorWorld world = new ActorWorld (); Spiralbug bug 1 = new spiralbug (0); world.add (new location (4, 4), bug 1); World.show ();}}   

and for spiralbug

  import info.gridworld.actor.bug; import info.gridworld.actor .actor; Import info info.gridworld.grid.Location; public class spiralbug bugs {private int side length; private int phase; public spiralbug (int n) {sideLength = n; phase = 0;} public zero act (if ( Dum & amp; lt; Side lang & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp;;);;;;; moves;; ;;;;;;;;;;;23; and feet ;;;;; b); turn (); phase = 0; sidelength ++;}} GetNameCol (), getGrid (). GetNumRows ()); moveTo (loc); side length = 0;}}   pre> 

My real question is, what should I do to reset the bug to run again to run the bug?

You are calling this method within yourself, causing one There is a stack overflow error.

  to move public zero (location new location) {location public = new location (getGrid (). getNumCols (), getGrid (). getNumRows ()); MoveTo (loc); Side lanal = 0; }   

This is the wrong method, it should be in the move () method. The conduction method takes a space and goes to that place, it should not be overridden.

Change it to:

  Public Zero move (location new location) {location public = new location (getGrid (.) GetNumCols (), getGrid () .getNumRows ()); MoveTo (loc); Side length = 0; }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -