Write an inheritance hierarchy for classes Quadrilateral, Trapezoidal, Parallogram, Rectangle and Square.Use Quadrilateral as the superclass of the hierarchy. Make the hierarchy as deep (i.e., as many levels) as possible.The private data of Quadrilateral should include the (x,y) co-ordinate pairs for the four end points of the Quadrilateral. Write a driver program that instantiates and displays object of each of these classes.(File must be save as: Assignment08.java)


import java.awt.Graphics;
import java.applet.Applet;
import javax.swing.JOptionPane;

class Quadrilateral
{
            private int x[]=new int[10];
            int i;
            String s[]={"x1= ","y1= ","x2= ","y2= ","x3=","y3= ","x4= ","y= 4"},st;

    Quadrilateral(int b[])
    {
                        for(i=0;i<8;i++)
                        x[i]=b[i];
            }
            void input()
            {
                        String st;
                        for(i=0;i<8;i++)
                        {
                                    st=JOptionPane.showInputDialog(s[i]);
                                    x[i]=Integer.parseInt(st);
                        }
            }

            void display(Graphics g)
            {
                        g.drawLine(x[0],x[1],x[2],x[3]);
                        g.drawLine(x[2],x[3],x[4],x[5]);
                        g.drawLine(x[4],x[5],x[6],x[7]);
                        g.drawLine(x[6],x[7],x[0],x[1]);
            }
}

class Trapezoid extends Quadrilateral
{

            Trapezoid(int b[])
            {
                        super(b);
            }

}
class Para extends Trapezoid
{

            Para(int a[])
            {
                        super(a);
            }

}
class Rec extends Para
{

                        Rec(int b[])
                        {
                                    super(b);
                        }
}
class Sq extends Rec
{

            Sq(int a[])
            {
                        super(a);
            }
}

            public class Assignment08 extends Applet
{
            int a[]={50,50,100,50,120,80,50,80};
            int b[]={125,50,175,50,200,80,150,80};
            int c[]={205,50,255,50,255,80,205,80};
            int d[]={260,50,290,50,290,80,260,80};
            Quadrilateral q;
            Trapezoid t;
            Para p;
            Rec r;
            Sq s;

            public void init()
            {
                        q=new Quadrilateral(a);
                        t=new Trapezoid(a);
                        p=new Para(b);
                        r=new Rec(c);
                        s=new Sq(d);
                        q.input();
            }

            public void paint(Graphics g)
            {
                        q.display(g);
                        t.display(g);
                        p.display(g);
                        r.display(g);
                        s.display(g);
            }
}


////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........