import java.awt.Graphics; 
import java.applet.Applet; 
import nokta; 
class dikDortgen 
{ 
    protected nokta n1,n2; 
    //kurucu metot metot girdisi x1,y1,x2,y2 
    public dikDortgen(double x1, double y1,double x2,double y2) 
    { 
        n1=new nokta(x1,y1); 
        n2=new nokta(x2,y2); 
    } 
    //kurucu metot, method girdisi iki nokta 
    public dikDortgen(nokta nokta1,nokta nokta2) 
    { 
        n1=new nokta(nokta1.x,nokta1.y); 
        n2=new nokta(nokta2.x,nokta2.y); 
    } 
    public void dikdortgengir(double x1, double y1,double x2,double y2) 
    { 
        n1.noktagir(x1,y1); 
        n2.noktagir(x2,y2); 
    } 
    public String toString() 
    { 
        return "dikdortgen : ("+n1.toString()+","+n2.toString()+")"; 
    } 
    public double alan() 
    { 
    return (n1.Xoku()-n2.Xoku())*(n1.Yoku()-n2.Yoku()); 
    } 
    public double cevre() 
    { 
    return 2*(n1.Xoku()-n2.Xoku())+ 2*(n1.Yoku()-n2.Yoku()); 
    } 
} 
  
public class dikdortgentesti extends Applet 
{ 
    public void paint(Graphics g) 
    { 
    dikDortgen cokguzelbirdikdortgen=new dikDortgen(1,1,2,2); 
    g.drawString(cokguzelbirdikdortgen.toString(),20,20); 
    g.drawString("Alan : "+ cokguzelbirdikdortgen.alan(),20,35); 
    } 
}

