import java.util.*;
import java.awt.*;
import java.io.*;
//import java.applet.Applet;

// A non-empty (or "live") cell in the Game of Life.
// ----------------------------------------------------------------------
public class LiveCell extends Cell {

    // The number of generations for which I have been alive.
    int age;
    
    // Constructor:  This gets called for each newly created LiveCell.
    // Set my age to 0, my color to cyan, and my display character to 'X'.
    // ------------------------------------------------------------------
    public LiveCell () {
        age = 0;
        ident = 'X';
        c = Color.cyan;
    }


    // If n is 2 or 3 then keep myself alive in the next
    // generation; otherwise, kill myself and return an EmptyCell.
    // ------------------------------------------------------------------
    public Cell evolve (int n) {
        // Make me one unit older, and a little darker.
        age ++;
        c=ColorUtils.darker (c, .7); 

        return (n == 2) || (n == 3)
            ? (Cell) this
            : (Cell) new EmptyCell();
    }
}
