(+84) 236.3827111 ex. 402

Xây dựng lớp Diem trong mặt phẳng Oxy


public class Diem {
private int ox,oy;
Diem(){ ox = oy =0; }
Diem (int x, int y){ ox =x; oy =y; }
public int getOx() { return ox; }
public void setOx(int ox) { this.ox = ox; }
public int getOy() { return oy; }
public void setOy(int oy) { this.oy = oy; }
public double modul(Diem a){
return Math.sqrt((ox-a.ox)*(ox-a.ox)+(oy-a.oy)*(oy-a.oy));
}
public String toString(){
return " ( "+ox +" , " + oy +") ";
}
}