Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» NewBlueFx TotalFX Windows-FL | 1.11 GB
Tue Dec 17, 2013 12:42 pm by titquarra

» NewBlueFx TotalFX Windows-FL | 1.11 GB
Tue Dec 17, 2013 12:42 pm by titquarra

» Celebrity.Sex.Tape.UNCUT.&.UNRATED.2012.720p.BRrip.x264.YIFY.mp4
Tue Dec 17, 2013 8:32 am by titquarra

» Maya Autodesk Personal Learning Edition 8.5
Tue Dec 17, 2013 7:47 am by titquarra

» Tuyệt Kỹ Đong Giai Chân Kinh (tuyệt Kỹ cua trai)
Thu Aug 23, 2012 5:38 am by Admin

» Tuyệt kỹ cua giai
Thu Aug 23, 2012 5:36 am by Admin

» NETCAT.........
Mon Aug 13, 2012 6:35 am by Admin

» Bảo mật CSDL bằng phương pháp mã hóa.
Tue Apr 17, 2012 10:04 pm by Admin

» Hàm mã hóa MD5 bằng JavaScript
Tue Apr 17, 2012 10:03 pm by Admin

Shopmotion


Affiliates
free forum


Tinh do dai doan thang

View previous topic View next topic Go down

Tinh do dai doan thang

Post  Admin on Thu Feb 10, 2011 8:10 am

Dau tien ta co lop diem

Code:
class Point
{
   public  int x;
   public  int y;
   public Point()
   {
      x=1;
      y=1;
   }
   //
   public Point(int X,int Y)
   {
      x=X;
      y=Y;
   }
   public String ShowPoint()
   {      
      String temp;
      temp="Diem co toa do la: (" + x + "," + y + ")";
      return (temp);
   }
   
}

Dua vao lop diem tren ta khai bao mot duong thang gom hai diem va sau do tinh khoang cach hai diem cua mot doan thang

Code:
class Line extends Diem
{
   private  Point ePoint;
   private  Point fPoint;
   public Line()
   {
      Point p1=new Point(1,1);
      Point p2=new Point(1,1);
      ePoint=p1;
      fPoint=p2;
   }
   public Line(Point p1,Point p2)
   {
      ePoint=p1;
      fPoint=p2;
   }
   public double DD(Line k)
   {
      double kk;
      int Ax=k.ePoint.x;
      int Ay=k.ePoint.y;
      int Bx=k.fPoint.x;
      int By=k.fPoint.y;
      kk=Math.sqrt(((Ax-Bx)*(Ax-Bx))+((Ay-By)*(Ay-By)));
      return (kk);
   }
   public double DD(Point p1,Point p2)
   {
      double kk;
      int Ax=p1.x;
      int Ay=p1.y;
      int Bx=p2.x;
      int By=p2.y;
      //+((Ay-By)^2)
      kk=Math.sqrt(((Ax-Bx)*(Ax-Bx))+((Ay-By)*(Ay-By)));
      return (kk);
   }
   public void ShowLine()
   {
      String s;
      s="Toa do dau: (" + ePoint.x+","+ePoint.y+") toa do cuoi: (" + fPoint.x+","+fPoint.y+")";
      System.out.print(s);
   }
}

Admin
Admin

Tổng số bài gửi : 782
Join date : 2009-08-15

View user profile http://hackis.forumotion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum