Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is Java problem this is the questions and i have some of the code already. Your program will implement the following two interfaces: -Interface

This is Java problem this is the questions and i have some of the code already.

Your program will implement the following two interfaces:

-Interface LifeForm: This interface defines the methods necessary for a life-form to participate in the simulation. It defines the following methods: getChar(): Returns a character to display on the screen getX(),

getY(): Returns the x & y position of the life-form setX(int x), setY(int y): Set the x & y position of the life-form o Interface Moveable: This interface defines the move() method necessary for every life-form to make a legal move in different directions.

Your program will implement five classes. The behavior of each class is described below:

-An abstract class AbstractLifeForm that implements the LifeForm interface: Data Fields: x and y position of a life-form. Constructors: - A default constructor to create an instance of the Java Object class. - Another constructor to create an abstract life form with initial x and y positions passed as parameters. Behavior: - Override the get and set methods defined in the LifeForm interface. - Override the toString() method to display the x and y positions.

these are the code

image text in transcribed

these two are the one i stuggle with.

The following four classes are different types of life-forms. Three of these classes also implement the interface Moveable (except for the Plant which remains stationary). The general properties are defined as follows: 1. Plant class: Denoted by the constant character P. Constructors: 1) A default constructor and 2) a constructor that takes in the initial x and y positions as the parameters. Behavior: Override the getChar()method.

2.Sparrow class: Denoted by the constant character S. A sparrow can move in either of the 4 directions (North, South, East, West). Constructors: 1) A default constructor that sets the default direction (you can choose the initial direction) and the move count to 1. 2) A constructor that takes in the initial x and y positions as the parameters. Behavior: Override the getChar()method. Override the move()method. The sparrow moves in any of the 4 directions random cell steps at a time. (i.e after every random cell steps forward or backward change the direction of sparrow)

how do i make these do i implement moveable and lifeform or just lifeform?

Interface LifeForm (Filenamc LifeForm.javal oublic Interface LifeFom ( public char getChar: public int getxD: uublic int gelYD public void setXint x public vold sety(Int yl; Interface Moveable (Filename Moveable.java) oublic interface Moveable vublic void movell class AbstractLifeForm (Filename- AbstractLifeForm.java) vublic abstract class AbslracLifeFor mplemels LifeFurm, Moveablel private int X; prvate Int Y default constructor oublic AbstractuifeFormo oublic AbstractLifeFormlint x, int y) ovcrriding the methods from interfaces Override public vold setxint x @Override public void set(int y) @Override public String toString return X-XY-"+Y

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago