public boolean isSquare(Cordinate[] cordinates){
        Cordinate startPoint = cordinates[0];
        int a1 = distanceSquare(startPoint, cordinates[1]);
        int a2 = distanceSquare(startPoint, cordinates[2]);
        int a3 = distanceSquare(startPoint, cordinates[3]);
        
        
        if(a1 == a2){ //then 0,3 is diagonal
            return compare(cordinates[3],cordinates[1],cordinates[2],a1,a3);
        }else if(a1 == a3){
            return compare(cordinates[2],cordinates[1],cordinates[3],a1,a2);
        }else if(a2 == a3){
            return compare(cordinates[1],cordinates[2],cordinates[3],a2,a1);
        }else{
            return false;
        }
    }
Given four points in any order determine if they form a square
Test cases
Less than or more than 4 points in input
Points could be in any quadrants e.it neg and pos allowed
src/com/interview/misc/FourPointsFormSquare.java