Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
I have provided you with an interface for the chicken class. Your base class will implement this interface and add the required methods. (Theres three classes here board, game chicken)Then, You will have two classes. A defensive class and an offensive one. These classes will extend the base functionality of the chicken class to be representative of their names. Finally,You will create at least 6 sub classes for the two previously described sub classes. Don't worry, they don't need to modify two much. Just be creative. For instance the two classes I have thought of are a fried chicken and a rubber chicken. The fried chicken has a longer range of fire than normal and the rubber chicken can absorb more damage than normal. It can also self heal. Feel free to do whatever you want.
---------------------------------------------------------------------------------------------------------------- The interface:
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions