logo Practice-It logo

Elephant

Related Links:
Author: Marty Stepp

("Critter" classes come from the University of Washington's CSE 142 Critters homework assignment. See the assignment spec for more information.)

Define a Critter class named Elephant with the following behavior:

constructor public Elephant(Attack attack)
(attack will be one of Attack.ROAR, Attack.POUNCE, or Attack.SCRATCH)
color gray (Color.GRAY)
eating behavior upon birth, decides either to always eat (true) or never eat (false) throughout its lifetime
fighting behavior uses the attack that was passed to the constructor
movement behavior prefers to move west if it is not in the horizontal center of the world;
otherwise, prefers north if it is not in the vertical center of the world;
but will not move onto a square occupied by another Elephant
toString "J" if this Elephant is hungry (if eat would return true); otherwise "j"
Type your solution here:


This is an inheritance problem. Write a Java class using inheritance. (You do not need to write any import statements.)

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.