This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Error on program. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error on program." Watch "Error on program." New topic
Author

Error on program.

Julie Mendez
Greenhorn

Joined: Oct 04, 2004
Posts: 7
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
:::::::


<b><i>To err is human but to really mess up the things you need a computer </b></i>
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
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 ]

Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Julie Mendez
Greenhorn

Joined: Oct 04, 2004
Posts: 7
ty and ty
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
YW YW!
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
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


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
 
wood burning stoves
 
subject: Error on program.
 
Similar Threads
Help With Snake Game
Random Number Generator Error
3D array Figure
Trouble Printing with java 1.4!
Help with Arrays