Find the type of quadrilateral - Java Quiz Question



Write a program to get the type of the quadrilateral formed by the given four points. The list of valid types are Parallelogram, Rectangle, Rhombus, Square, Trapezoid and Irregular Quadrilateral. Points are given in anti clock wise direction starting from bottom left point.

Input (Point, Point, Point, Point) Output (boolean)
[4, 5], [6, 5], [6, 7], [4, 7] Square
[-8, 1],  [-5, 1], [-4, 4], [-7, 4] Parallelogram
[-4, 0], [0, -5], [4, 0], [0, 5] Rhombus
[6, -6], [8, -6], [8, -4], [6, -1] Trapezoid
[1, 0], [1, 2], [1, 3], [0, 2] Irregular Quadrilateral

class ClassifyQuadrilateral

{    public static void main(String s[])
    {
        Point firstPoint = new Point(4, 5);
        Point secondPoint = new Point(6, 5);
        Point thirdPoint = new Point(6, 7);
        Point fourthPoint = new Point(4, 7);
        System.out.println("The quadrilateral type is : " + classifyQuadrilateral(firstPoint, secondPoint, thirdPoint, fourthPoint));

    }


public static String classifyQuadrilateral(Point firstPoint, Point secondPoint, Point thirdPoint, Point fourthPoint) {
//Write code here to identify the type of the quadrilateral formed by the given points
}

//If required write any additional methods here
}
class Point {

double x;
double y;

Point(double x, double y) {
this.x = x;
this.y = y;
}
}