2d world of ants and doodlebugs, JAVA Programming

Assignment Help:
We 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);

}
}
this is my code but the organisms are not moving

Related Discussions:- 2d world of ants and doodlebugs

Explain about the security aspect of java, Java has some bugs in its applet...

Java has some bugs in its applets. Java team stated that they have zero tolerance over security features and subsequent editions of Java are managing Bug free environment. Some of

Assistance for json authentication problem rss/aol/android, Assistance for ...

Assistance for JSON authentication problem RSS/AOL/Android The key problem we face is how to authenticate afterward the user logged in the webview as well as then parse the JSON

What is xmlbeanfactory, BeanFactory has many executions in Spring. But one ...

BeanFactory has many executions in Spring. But one of the most useful one is org.springframework.beans.factory.xml.XmlBeanFactory, which loads its beans based on the definitions ha

Component developer to code in java, Component Developer to code in Java: ...

Component Developer to code in Java: Worked for Sansri's Gateway as Software Engineer . Here I Worked as a Component Developer to code in Java and J2EE technologies Here Ensu

Javascript validarion, 1. Obtaining the new script: Download and save the a...

1. Obtaining the new script: Download and save the attached comment CGI mailer script form-mail2.pl to your server''s cgi-bin directory, and change the permissions on the script to

What information is needed to create a tcp socket, The Local Systems IP Add...

The Local Systems IP Address and Port Number and the Remote System's IPAddress and Port Number.

Design a system program, System Program Project Description: I want s...

System Program Project Description: I want someone who can study my existing program and from there the updates may be done Skills required: Java, Oracle, MySQL, Softwa

Need simple desktop software, Need Simple Desktop Software I am seeking ...

Need Simple Desktop Software I am seeking a software that can do the subsequent: 1. Check position for a URL in Google, Yahoo, Bing. 2. Check position for a YouTube video

OOP, differentiate between states and behaviors of n object

differentiate between states and behaviors of n object

What is pop, The Post Office Protocol is an application-level protocol with...

The Post Office Protocol is an application-level protocol within an intranet which is used by the local e-mail clients to send and retrieve e-mails from a remote server those are l

Write Your Message!

Captcha
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