import java.awt.*;

/**
 * @author  Heinze, Pausch, Robl
 * @version 1.0
 */
public class Food
{
  /** food_type: border */
  public static final int TYPE_BORDER=0;
  /** food_type: very bad food */
  public static final int TYPE_VERYBAD=1;
  /** food_type: bad food */
  public static final int TYPE_BAD=2;
  /** food_type: no food */
  public static final int TYPE_NOTHING=3;
  /** food_type: good food */
  public static final int TYPE_GOOD=4;
  /** food_type: very good food */
  public static final int TYPE_VERYGOOD=5;

  /** food_type: the lowest-energy food */
  public static final int TYPE_MINFOOD=TYPE_VERYBAD;
  /** food_type: the best-energy food */
  public static final int TYPE_MAXFOOD=TYPE_VERYGOOD;


  /** the type of this food*/
  private int food_type;
  /** energy level of this food */
  private double food_energy;
  /** array of colors to avoid a tons of useless instances of the class Color*/
  private Color color[]=new Color [20];

  /**
  * creates a TYPE_NOTHING food
  */
  public Food()
  {
    clear();
  }

  /**
  * creates food of a special type
  * @param type type of this food
  */
  public Food(int type)
  {
    settype(type);
  }

  /**
  * sets the foodtype of this food
  * @param type type of this food
  */
  public void settype(int type)
  {
    if (type<TYPE_BORDER) type=TYPE_BORDER;
    if (type>TYPE_MAXFOOD) type=TYPE_MAXFOOD;

    food_type=type;

    switch (food_type)
    {
      case TYPE_BORDER:
        food_energy=-9999.0;
        break;
      case TYPE_VERYBAD:
        food_energy=-100.0;
        break;
      case TYPE_BAD:
        food_energy=-30.0;
        break;
      case TYPE_NOTHING:
        food_energy=0.0;
        break;
      case TYPE_GOOD:
        food_energy=30.0;
        break;
      case TYPE_VERYGOOD:
        food_energy=100.0;
        break;
    }

    // create food colors only once - increases performance!
    int i=0;
    color[i++]=new Color(80,80,80);
    color[i++]=new Color(255,0,0);
    color[i++]=new Color(255,255,0);
    color[i++]=new Color(0,0,0);
    color[i++]=new Color(0,255,0);
    color[i++]=new Color(255,0,255);
  }

  /**
  * returns the type of this food
  * @return food type
  */
  public int gettype()
  {
    return food_type;
  }

  /**
  * returns the color of this food
  * @return food color
  */
  public Color getcolor()
  {
    return color[food_type];
  }

  /**
  * returns the energy level of this food
  * @return energy level
  */
  public int getenergy()
  {
    return (int) food_energy;
  }

  /** returns the foodtype to TYPE_NOTHING */
  public void clear()
  {
    settype(TYPE_NOTHING);
  }
}