Create a world class that contains a 2d array

Assignment Help JAVA Programming
Reference no: EM1399893

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: EM1399893

Questions Cloud

What is the structure of a g-protein : how can a G-protein open an ion channel either directly or through a protein kinase enzyme?
Scatter plot and regression line : A scatter plot and regression line can be used for all of the following EXCEPT
Describe the structure of eukaryotic chromatin : Describe the structure of eukaryotic chromatin and how this structure must be remodeled for transcription to occur. You must understand the role of histones, histone modifications, DNA modifications and DNA binding proteins.
Example of a two sample test for proportion or mean : Explain in your own words how to recognize a situation where you needed to use a two-sample test. Give a unique example of a two sample test for proportion or mean. Make sure to detail why only a two sample test would suffice.
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 move() method the organism should move randomly one step at the time.
Community services code of ethics in ethical leadership : Write a 200- to 300-word response to the following: Community Services Code of Ethics in Ethical Leadership in Human Services states, "Whatever your personal feelings about justice and suitability of particular laws.
Discuss the purpose of registering securities : Analyze why you think that the Securities Act of 1933 allows for an exemption to a nonprofit educational organization? What is the purpose of registering securities before they are offered for sale?
Describe the expression of a gene : Describe the expression of a gene as it occurs in a eukaryotic cell, starting with the gene and ending in a vesicle. What takes place in each subcellular organelle? Briefly discuss how this differs from a prokaryotic cell.
Examples of the populations parameters : What are examples of the populations parameters we are trying to estimate for sample data?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write down java program for furniture company

Write down a Java program for the furniture company. Ask user to select P for Pine, O for Oak or M for Mahogany. Illustrate price of table manufactured with chosen wood.

  Write java program which simulates flipping of coin

Write a Java program which simulates flipping of coin 1000 times and prints total number of heads and tails. You should create a class.

  Write java program to store values retrieved from user-array

Write a Java program named Arrays6_2GF.java Use an array to store values retrieved from user input. The number of integers to be entered (the length of the array )should also be retrieved through user input.

  Develop java applet that will help elementary school student

Develop a Java applet that will help an elementary school student learn multiplication. Use the Math.random method or a Random object to produce two positive one-digit integers.

  Java program for creating a order menu

Assume your consulting company has been hired to construct a program that meets the following requirements.

  Write a program that reads a set of floating-point

Write a program that reads a set of floating-point data values from the input.

  Develop java package comprising of class using encapsulation

Develop the Java package comprising of Class and Student with the given requirements. Encapsulation, Method to print student details alone.

  Java program to declares integer array

Write a complete Java program to declares integer array, intArray, and initialize it to {1, 2, 3, 4, 5, 6, 7}.

  Java class to accept a user-s hourly rate of pay

Write a class that accepts a user's hourly rate of pay and the number of hours worked. Display the user's gross pay, the withholding tax (15% of gross pay), and the net pay (gross pay - withholding).

  Implement simple java program to input syllabus grades

To implement simple Java program to input (hypothetical) syllabus grades, computing and displaying both normal Mean and Harmonic Mean.

  Display student details and classes in applet

Display student details and classes they have enrolled in Applet. The Applet should have following features. Update and View.

  Write java program to read present basic hourly wage

Write down a java program which will input 1. Read present basic hourly wage. Read in workers fist name and socond name.

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