Alright, this is for a project designed to make us use inheritance. This is Creature, which is a subclass of Thing. Creature is supposed to be able to eat, move and tell what it ate. Here are my issues:
1. How do I use a constructor from Thing in Creature?
2. How do I get the whatDidYouEat method to get the info from the eat method? What I've done with my lastEaten and aThing vars doesn't work.
3. How do I get whatDidYouEat to check to see if the creature has eaten?
public abstract class Creature extends Thing{
String lastEaten;
/** eat method */
public void eat(Thing aThing){
System.out.println(super.toString() + " has just eaten a " + aThing);
lastEaten = aThing;
}
/** move method */
public abstract void move();
/** what did you eat method*/
public void whatDidYouEat(){
if(lastEaten.equals(aThing)){
System.out.println(super.toString() + " has eaten a " + lastEaten);
}
else{
System.out.println(super.toString() + "has had nothing to eat!");
}
}
}