logo Practice-It logo

Frog

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 Frog with the following behavior:

constructor public Frog(int age)
The age passed will be between 1 and 9 inclusive.
color green
eating behavior never eats (this is the default eating behavior)
fighting behavior always forfeits in a fight (this is the default fighting behavior)
movement behavior moves east sometimes, or stays put (center), based on the frog's age:

If the frog is 1 year old, moves to the east every move.
E, E, E, E, E, E, E, E, E, E, ...

If the frog is 2 years old, moves to the east once every 2 moves.
C, E, C, E, C, E, C, E, C, E, ...

If the frog is 3 years old, moves to the east once every 3 moves.
C, C, E, C, C, E, C, C, E, C, ...

...

If the frog is 9 years old, moves to the east once every 9 moves.
C, C, C, C, C, C, C, C, E, C, ...

toString "F"
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.