logo Practice-It logo

Ostrich

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.)

Write a complete Critter class Ostrich, including its movement and color behavior.

An Ostrich object first stays in the same place for 10 moves, then moves 10 steps to either the west or the east, then repeats. In other words, after sitting still for 10 moves, the ostrich randomly picks to go west or east, then walks 10 steps in that same direction. Then it stops and sits still for 10 moves and repeats. Whenever an Ostrich is moving (that is, initially and whenever its last call to getMove returned a direction other than Direction.CENTER), its color should be white (Color.WHITE). As soon as it stops moving, and initially when it is placed into the critter world, its color should be cyan (Color.CYAN). When randomly choosing west vs. east, the two directions should be equally likely.

You may add anything needed (fields, other methods) to implement the above behavior appropriately. All other behavior not discussed here uses the default values.

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.