Algorithm for finding a (x,y) within and on perimeter of a square and cross
<p>I have a school assignment, which requires me to find out whether a certain point (x,y) is inside a shape which for example lets say a square. </p>

<pre><code>Class Square
private:
    int coordX[4];
    int coordY[4];
</code></pre>

<p>A cross has 12 points however,</p>

<pre><code>Class Cross
private:
    int coordX[12];
    int coordY[12];
</code></pre>

<p>These are the attributes for the square. So lets say the square coordinates are (1,1) (1,4) (4,1) (4,4), how should I go about finding out whether the point (2,2) is inside the square?</p>

<pre><code>bool isPointInShape (int, int)
</code></pre>

<p>The function is meant to take in two integers which is the point you want to check for, and it will return true or false.</p>

<pre><code>bool isPointOnShape (int, int);
</code></pre>

<p>Same for the function which checks whether the point is on the perimeter of the shape.</p>

<p>Can someone help as to what is the algorithm to figure out how to calculate these 2 functions?</p>