logo CodeStepByStep logo

Butterfly

("Critter" classes come from Marty Stepp's "Critters" homework assignment. See "Critters spec" link above for more information.)

Define a Critter class named Butterfly with the following behavior:

constructor public Butterfly()
color yellow (Color.YELLOW)
eating behavior never eats (this is the default behavior)
fighting behavior always forfeits (this is the default behavior)
movement behavior moves N, W, N, E, then repeats
toString alternates between "x" and "-" on each move
Inheritance: Write a Java class using inheritance.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.