src/GameOfLife/Board.php
/**
     * Checks whether a board is the same like this board.
     *
     * @param Board $_compareBoard The board that will be compared
     *
     * @return Bool True: The boards are equal
     *              False: The boards are not equal
     */
Checks whether a board is the same like this board.
@param Board $_compareBoard The board that will be compared

@return Bool True: The boards are equal
False: The boards are not equal
Checks whether a board is the same like this board . @param Board $_compareBoard The board that will be compared @return Bool True : The boards are equal False : The boards are not equal
public function equals(Board $_compareBoard): Bool
    {
        if ($this->gameStep() == $_compareBoard->gameStep() &&
            $this->hasBorder() == $_compareBoard->hasBorder() &&
            $this->height() == $_compareBoard->height() &&
            $this->maxSteps() == $_compareBoard->maxSteps() &&
            $this->width() == $_compareBoard->width()
        )
        {
            $fieldsEqual = true;
            foreach ($_compareBoard->fields() as $y => $row)
            {
                foreach ($row as $x => $field)
                {
                    $boardField = $this->fields()[$y][$x];
                    if ($field->value() != $boardField->value() ||
                        $field->x() != $boardField->x() ||
                        $field->y() != $boardField->y()
                    )
                    {
                        $fieldsEqual = false;
                        break;
                    }
                }
            }
            if ($fieldsEqual) return true;
        }
        return false;
    }
public function equals ( Board $ _compareBoard ) : Bool { if ( $ this -> gameStep ( ) == $ _compareBoard -> gameStep ( ) && $ this -> hasBorder ( ) == $ _compareBoard -> hasBorder ( ) && $ this -> height ( ) == $ _compareBoard -> height ( ) && $ this -> maxSteps ( ) == $ _compareBoard -> maxSteps ( ) && $ this -> width ( ) == $ _compareBoard -> width ( ) ) { $ fieldsEqual = true ; foreach ( $ _compareBoard -> fields ( ) as $ y => $ row ) { foreach ( $ row as $ x => $ field ) { $ boardField = $ this -> fields ( ) [ $ y ] [ $ x ] ; if ( $ field -> value ( ) != $ boardField -> value ( ) || $ field -> x ( ) != $ boardField -> x ( ) || $ field -> y ( ) != $ boardField -> y ( ) ) { $ fieldsEqual = false ; break ; } } } if ( $ fieldsEqual ) return true ; } return false ; }
Checks whether a board is the same like this board.
Checks whether a board is the same like this board .
/** @var Field $boardField */ /** @var Field $field */