JAVA 2D GRID GAME I need to create a 2D grid game whereby a cat and canary(ies) move on a 2d grid. The canary tries to eat seeds and the cat tries to eat the canary. How do I move these animals to a...




JAVA 2D GRID GAME


I need to create a 2D grid game whereby a cat and canary(ies) move on a 2d grid. The canary tries to eat seeds and the cat tries to eat the canary. How do I move these animals to a random place on the grid? How do I determine if a location is occupied or not? How do I determine a winner at the end based on the amount of energy available? The classes are below with most of the code written apart from the start and move method which is needed to create this game.

Import  java. Until .Array List; public class Grid implements Grid Object { private Array List locations; private in t size; public Grid(in t size) { locations = new Array List(size*size); this. size=size; for(in t i=0; i

Cat  = new Cat("feli x"); grid. Add Avatar (cat, 0, 2); grid. start(); } void start(){ } public interface Grid Object { } public class Location { public final in t x; public final in t y; private Grid Object grid Object; private Boolean  occupied; public Location  ( in t  x ,in t y){ this .x=x; this .y=y; } public void set Grid Object(Grid Object grid Object){ this. grid Object=grid Object; occupied=true; } public bole an get Occupied(){ return occupied; } @Override public bole an equals(Object object){ if(object==null){ return false; } if(object instance of Location){ Location  = (Location) object; if(location .x == x && location. y == y){ return true; } } return false; } }






May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here