TypeError: No matching declaration found after argument-dependent lookup

by user54621   Last Updated July 12, 2019 08:28 AM

ERROR:TypeError: No matching declaration found after argument-dependent lookup.require (positionIsInBounds(xpos,ypos)); ^-----^

pragma solidity ^0.5.1;

contract TicTacToe { 
//addresses of the players who are competing.
    address player1;
    address player2;
    uint8 current_move =0;

    enum SquareState {empty, x, o}
    SquareState[3][3] board;

    constructor(address _player2) public {
        player1 = msg.sender;
        player2 = _player2;
    }
    //
    function stateToString() public view returns (string memory){
         return string(abi.encodePacked("\n",
         rowToString(0),"\n",
         rowToString(1),"\n",
         rowToString(2),"\n"
         ));
    }

    //string representation of a board row
    function rowToString(uint8 ypos) public view returns(string memory){
        return string(abi.encodePacked(squareToString(0,ypos), "|",squareToString(1, ypos), "|",squareToString(2, ypos)));
    }

    //string representation of a square on the board
    function squareToString(uint8 xpos, uint8 ypos) public view returns (string memory) {

        require (positionIsInBounds(xpos,ypos));
        if(board[xpos][ypos] == SquareState.empty){
            return " ";
        }
        if(board[xpos][ypos] == SquareState.x){
            return "x";
        }
        if(board[xpos][ypos] == SquareState.o){
            return "o";
        }
    }

    function positionIsInBounds(uint8 xpos, uint8 ypos) public pure returns(uint8,uint8) {
        return (xpos>=0 && xpos<3 && ypos>=0 && ypos<3);
    }


}


Related Questions


Updated July 12, 2019 12:28 PM

Updated August 04, 2018 02:28 AM

Updated December 09, 2017 15:28 PM

Updated July 21, 2019 16:28 PM

Updated October 08, 2017 20:28 PM