Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a JAVA question. I only covered the concepts before classes section and classes section. So please don't explain it with further concepts. It's
This is a JAVA question. I only covered the concepts before classes section and classes section. So please don't explain it with further concepts. It's really hard for me to understand it. Appreciated!
This is a review exercise, so as such you may want to spend some time reviewing past concepts. The primary goal of the exercise is to get your mind working and in the correct space In this activity you will create a grid locations that goes from-10 x 10,-10 ys 10 On this grid you will keep track of various animal objects as they move around the grid. Make sure that al aals stay within that grid at all times Using Java, create the following classes and primary program that uses the classes that you developed. INSTRUCTIONS Create the following classes. ANIMAL CLASS Create an Animal class. Each animal has a name, an x and y integer coordinate and a max speed which needs to be between 2 and 5. The Animal class should have at minimum the following methods below: .A default constructor that starts the animal at 0,0 with a name of "unknown" and a max speed of 2. A parameter constructor that allows the programmer to input all 4 pieces of information. o Check for the constraints. If the input value is invalid, adjust it any way you deem necessary getx() gety( toString() This should print out the name and coordinates of the animal. o touching(Animal x) o This method should determine if the animal is on the same spot as the other animal (x). It should return a Boolean value of true if they are touching, and false if they are not on the same location. move o This should move the animal in a single random direction (up, down, left, right) a random x number of units, where x is between 1 and the max speed (inclusive). o Note that there are no parameters. The animal should self move. o Check for the constraints. If the animal has moved outside the arena, adjust it any way you deem necessary to keep it in the grid. MAIN CLASS Inside your main class do the following .Create an array that can hold 5 animals. . Create a fight counter that starts at zero and a round counter . Fill the array with 5 different animals with different starting locations and values. You can decide where they start and the name. Print out the starting locations and names of all 5 animals. Then do the following loop . . o Move all 5 animals randomly Check all 5 animals to see if any of them are on the same spot. If any of the animals are touching it should print out the word "FIGHT" to the screen and show the names of the two animals that are touching o o o Print out the current locations and names of all 5 animals. o Print a line "+-++-+-+-+-+-+-+-+-+between each round of the movement. . Repeat the loop above until there are at least five fights. . Print out the total number of fights. Print out the total number of rounds that it took. . Finally print out the final location of all the animals. BEFORE SUBMISSION Before submitting your assignment, make sure your program is correctly Java Documented and is listed as your name as the authorStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started