Skip to content
Snippets Groups Projects
Select Git revision
  • b3b75a8a3e25879de2a5e368583fc286b6e6531a
  • main default protected
  • correction_video
  • going_further
  • ImprovedMouseInteraction
  • final2023
  • template
  • ModifGUI
8 results

SeedsState.java

Blame
  • Forked from YAGOUBI Rim / Game of life Template
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    SeedsState.java 769 B
    package model.automata;
    
    import javafx.scene.paint.Color;
    import model.State;
    
    import java.util.List;
    
    import static model.automata.BriansBrainState.countList;
    
    public enum SeedsState implements State<SeedsState> {
        ON, OFF;
        @Override
        public Color getColor() {
            return switch (this) {
                case ON -> Color.WHITE;
                case OFF -> Color.BLACK;
            };
        }
    
        @Override
        public SeedsState next() {
            return switch (this) {
                case ON -> OFF;
                case OFF -> ON;
            };
        }
    
        @Override
        public SeedsState update(List<State<SeedsState>> neighbours) {
            return switch (this) {
                case ON -> OFF;
                case OFF -> countList(ON,neighbours) == 2 ? ON: OFF;
            };
        }
    
    }