OK so I am trying to manually feed (add energy) my "friendly cat" to have him wake up. After 10 steps with out eating the pizza he falls asleep and you have to manually feed him to wake him up. Here is the code I have so far...any help would be appreciated.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
*
* FriendlyCat describes cats that
* - move and jump when corresponding control keys are pressed, when having enough energy
* - love pizzas and show their joy by dancing after eating three pizzas
*
*/
public class FriendlyCat extends Cat
{
private int pizzaEaten = 0;
private int energy = 10;
public FriendlyCat()
{
energy = 10;
pizzaEaten = 0;
}
public void act()
{
{
if (energy <= 0)
{
sleep(1);
return;
}
}
findPizza();
if (Greenfoot.isKeyDown("left"))
{
walkLeft(1);
energy --;
}
if (Greenfoot.isKeyDown("right"))
{
walkRight(1);
energy --;
}
if (Greenfoot.isKeyDown("down"))
{
jumpDown(1);
energy --;
}
if (Greenfoot.isKeyDown("up"))
{
jumpUp(1);
energy --;
}
if (energy <= 0)
{
sleep (1);
}
}
public void findPizza()
{
if (canSee(Pizza.class))
{
eat();
remove(Pizza.class);
pizzaEaten ++;
howManyEaten();
energy = energy + 5;
}
}
public void howManyEaten()
{
if (pizzaEaten == 3)
{
dance();
pizzaEaten = 0;
}
}
}

