you have to create a world class that contains a


You have to create a world class that contains a 2d array then create an abstract class called organism that contains move() method the organism should move randomly one step at the time.

public void move()

{

   Random r = new Random();

    int a = r.nextInt(4);

   if (a == 0)

       {

           if (y - 1 >= 0 && world.getAt(x, y - 1) == null)

               {

                  y -= 1; world.setAt(x, y, this);

                }

        }

  else if (a == 1)

   {

        if (y + 1 < World.WORLDSIZE && world.getAt(x, y + 1) == null)

             {

                  y += 1; world.setAt(x, y, this);

              }

   }

 else if (a == 2)

 {

          if (x - 1 >= 0 && world.getAt(x - 1, y) == null)

                { 

                     x -= 1; world.setAt(x, y, this);

                  }

   }

 else if (a == 3)

  {

          if (x + 1 < World.WORLDSIZE && world.getAt(x + 1, y) == null)

                   {

                        x += 1; world.setAt(x, y, this);

                    }

   }

Download:- java class.zip

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: you have to create a world class that contains a
Reference No:- TGS0486150

Expected delivery within 24 Hours