Question: JAVA Two chickens face each other on a 10x10 grid. One chicken is controlled by the computer. One chicken starts in the upper left corner

JAVA

Two chickens face each other on a 10x10 grid. One chicken is controlled by the computer. One chicken starts in the upper left corner and the other in the lower right corner. The chicken can move or shoot, but not both. The way the chicken moves is the way the chicken is pointed. It can change its direction, but this is one turn. The base chicken class can only move two squares in the direction it faces. The chicken can only shoot two squares away in a straight line the way it is facing. The chicken will have variables to store the Hit points. Hit points represent how many times it can be hit before it dies. I.E. if a chicken has 10 hit points and it is hit for 1 damage point it will have 9 hit points left. The amount of damage could change depending on which sub chicken is firing at it.

A turn consists of: Chicken 1 Move: Pick a direction and update square 2 spaces in that direction. If the chicken is at the end of the grid it can only go that far. Or Chicken 1 fire: Fire two squares away in the direction the chicken is facing. Check to see if chicken 2 is there, if so, deduct point(s) from chicken 2s hit points. If chicken 2s hit points are zero game is over. If not, chicken two takes turn. Or Chicken 1 will change directions and prepare to move or fire the next turn.

Using the following code , an interface for the chicken class.

--------------------------------------------------------------------------------------------------------------------------------------

public interface IChicken {

public void move_left();

public void move_right();

public void move_up();

public void move_down();

public int[] fire();

public void change_direction(int direction);

public int[] get_location();

public void hit(int damage);

public boolean is_alive();

public int set_vars(int min, int max,int var);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!