Hi, I am wondering how I would move a random Y value 50% of the time? This is for my fish actor. Here's the code I have.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Fish here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Fish extends Actor
{
/**
* Act - do whatever the Fish wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move();
// death();
{
// If object reaches right boundary, reset to the left
if (getX() >= getWorld().getWidth() - 1)
{
setLocation(0, getY());
}
setLocation (getX() + 1, getY());
}
}
public void move()
/**
* This method move the fish.
* (not part of the lesson)
*/
{
setLocation(getX()+1,getY());
}
}

