

import java.awt.*;

 class Population

   {

     private static final int MAX_POP = 1000;

     private Creature mr_primal;
     private Creature ms_primal;
     private Creature all_creatures[];
     private int how_many, max_health, avg_health, min_health;


     public Population()
        {
           all_creatures = new Creature[MAX_POP];
           all_creatures[0] = new Creature (150,50);
           all_creatures[1] = new Creature (170,89);
           all_creatures[2] = new Creature (100,202);
           all_creatures[3] = new Creature (78,65);
           how_many = 4;

        }

     public void drawStats(Graphics gp, int t, int x, int y)
         {
           gp.clearRect(x,y-10,400,20);
		   gp.drawString(" t = " +t + " with " +how_many+ " creatures" +
		                 " with " +max_health+ " max, " +avg_health+
		                 " avg, " +min_health+ " min, health", x, y);
		 }

     public void calculate_health_stats()
         {
           max_health = all_creatures[0].get_health();
           min_health = max_health;
           int total_health = max_health;
           int current_health;
           for(int k=1;k<how_many;k++)
              {
                current_health = all_creatures[k].get_health();
                if(current_health > max_health)
                   max_health = current_health;
                if(current_health < min_health)
                   min_health = current_health;
                total_health += current_health;
               }
           avg_health = total_health/how_many;
          }


     public void advance_time(int t)
         {
           for(int i=0;i<how_many;i++)   //  Move everyone
              all_creatures[i].move();
           calculate_health_stats();
         }



     public void paint(Graphics g)
        {
          for(int i=0;i<how_many;i++)
              all_creatures[i].paint(g);
         }

   }


