You have to create a world class that contains a 2d array

Assignment Help JAVA Programming
Reference no: EM13372098

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

Reference no: EM13372098

Questions Cloud

1 introductionin order to debug an application it is : 1 introductionin order to debug an application it is sometimes useful to know where a given object comes from or where
Huang is the son of successful malaysian business people : huang is the son of successful malaysian business people and works for his parents company. huang owns a home in a
1 ross whites machine shop uses 2500 brackets during the : 1. ross whites machine shop uses 2500 brackets during the course of the year and this usage is relatively constant
Create functions in filehow to code this functiondeclare : create functions in filehow to code this functiondeclare function inputs and outputsdownload-
You have to create a world class that contains a 2d array : you have to create a world class that contains a 2d array then create an abstract class called organism that contains
1 using the following fixed basket of goods basket 6 : 1. using the following fixed basket of goods basket 6 pizzas 12
Lee is taking some friends on a picnic theyll need to : lee is taking some friends on a picnic. theyll need to follow a path to get to the picnic spot. a map of the path is
1 the brain drain problem in the developing countries : 1. the brain drain problem in the developing countries refers to the fact the best-educated workersa. often emigrate to
Casea beautiful harbor town has the following : casea beautiful harbor town has the following characteristics it is located on an island that is mostly except for the

Reviews

Write a Review

JAVA Programming Questions & Answers

  Cognitive-based approaches to understanding motivation

Compare and contrast the need-based and cognitive-based approaches to understanding motivation?

  Using notepad that implements a basic text analyzer

Write a Java application using Notepad that implements a basic Text Analyzer.

  Write a java program that finds the temperature

Write a JAVA program that finds the temperature that is the same in both Celsius and Fahrenheit

  Write function in javascript to compute person-s gross pay

Write the function using JavaScript syntax to compute a person's gross pay for a week. The function should receive the number of hours worked and the rate of pay per hour.

  The goal is to create a project that would let a user

the goal is to create a project that would let a user compute area and perimeter of a polygon. restrict the type of

  The objective is to implement a menu-based system for bank

the objective is to implement a menu-based system for bank accounts in order to simulate a very simple banking system.

  Develop and test stand alone java applications

Demonstrate an understanding of Object-Oriented Programming concepts in Java.

  Write jvm program which accepts rpn expression

Write down the IJVM program which accepts RPN expression, with each operand and operator entered line by line. As each number (operand) is entered, push it on stack.

  Objective to learn the use of comments and basic math

objective to learn the use of comments and basic math operators.create a new folder called assign21 under

  The data-centric java agricultural image storing application

Develop and test a specified a data-centric Java application. The required application is described in the Agricultural Image storing application- case-study

  1 explain the differences between our specifications of the

1. explain the differences between our specifications of the sorted list adt and the binary search tree adt.2. define a

  You are a mighty warrior and armed with your trusty bow and

you are a mighty warrior and armed with your trusty bow and 3 arrows you enter the caves in search of the mighty

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd