logo CodeStepByStep logo

Snake

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

Define a Critter class named Snake with the following behavior:

constructor public Snake()
color red=20, green=50, blue=128
eating behavior never eats (this is the default eating behavior)
fighting behavior randomly choose to pounce or roar each time
movement behavior zig-zags down the map in the following pattern:
  • east once, south once,
  • west twice, south once,
  • east three times, south once,
  • west four times, south once,
  • east five times, south once,
  • ...
toString "S"
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.