-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBean.java
More file actions
40 lines (31 loc) · 755 Bytes
/
Bean.java
File metadata and controls
40 lines (31 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/****************************************************************
* Bean.java
*
*/
public class Bean {
private double relativeX;
private double relativeY;
public Bean(double x, double y) {
this.relativeX = x;
this.relativeY = y;
}
public double getX() {
return relativeX;
}
public void setX(double x) {
this.relativeX = x;
}
public double getY() {
return relativeY;
}
public void setY(double y) {
this.relativeY = y;
}
public double distanceFrom(Bean bean, int width, int height)
{
double dx = 1.0 * (this.relativeX - bean.relativeX) * width;
double dy = 1.0 * (this.relativeY - bean.relativeY) * height;
double dist = Math.sqrt(dx * dx + dy * dy);
return dist;
}
}