Skip to content
Snippets Groups Projects
Select Git revision
  • eebeac0902f1baa3fd554ea831ca38ad7d7a10cb
  • master default protected
  • patch-2
  • patch-1
4 results

Cell.java

Blame
  • Forked from DAS Shantanu / Prog2Aix-tp3
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Cell.java 1.85 KiB
    /**
     * {@link Cell} instances represent the cells of <i>The Game of Life</i>.
     */
    
    public class Cell {
        private boolean isAlive;
        private String color =  "Red";
    
        public void setColor(String hisColor) {
            color = hisColor;
        }
        public String getColor() {
            return color;
        }
    
        public Cell(){
            this.isAlive = false;
        }
    
        /**
         * Determines whether this {@link Cell} is alive or not.
         *
         * @return {@code true} if this {@link Cell} is alive and {@code false} otherwise
         */
    
        public boolean isAlive() {
            return this.isAlive;
        }
    
        /**
         * Determines whether this {@link Cell} is dead or not.
         *
         * @return {@code true} if this {@link Cell} is dead and {@code false} otherwise
         */
    
        public boolean isDead() {
            return !this.isAlive;
        }
    
        /**
         * Sets the state of this {@link Cell} to alive.
         *
         * @param cellState the new state of this {@link Cell}
         */
    
        public void setAlive() {
            this.isAlive = true;
        }
    
        /**
         * Sets the state of this {@link Cell} to dead.
         *
         * @param cellState the new state of this {@link Cell}
         */
    
        public void setDead() {
            this.isAlive = false;
        }
    
    
        /**
         * Change the state of this {@link Cell} from ALIVE to DEAD or from DEAD to ALIVE.
         */
    
        public void toggleState() {
            if(this.isAlive)
                this.isAlive = false;
            else
                this.isAlive = true;
        }