• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error on program.

 
Julie Mendez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using this code to make my ants move in all different direction {o-0=up, 1=down, etc.} but it keeps coming up w/ an error.


int move;

public void init()
{
move = 3;

while ( ( move < 0 ) || ( move > 3 ) )
{
(int)(Math.random() * move );
}
}

error message :::::::C:\Documents and Settings\Ashia\Desktop\INSY 3300\Homework\hw3.java:22: not a statement
(int)(Math.random() * move );
^
1 error
:::::::
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try assigning the cast value to a variable. That's what the compiler's looking for.

By the way, you'll soon get a message from one of the sheriffs that your name violates the JavaRanch rules for names. You may want to change that before they 'cuff you.
[ October 04, 2004: Message edited by: Jeff Bosch ]
 
Julie Mendez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ty and ty
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YW YW!
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Julie,

You should assign the new computed value back to your 'move' variable. If you don't, your ants won't get a new movement
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic