-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPunto.java
More file actions
60 lines (48 loc) · 1.02 KB
/
Punto.java
File metadata and controls
60 lines (48 loc) · 1.02 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package prg.es1;
import java.util.InputMismatchException;
public class Punto{
private double x;
private double y;
//COSTRUTTORI:
public Punto(){}
public Punto(double x, double y){
this.setX(x);
this.setY(y);
}
//METODI:
public Punto setX(double x){
this.x = x;
return this;
}
public Punto setY(double y){
this.y = y;
return this;
}
public void setXY(double x, double y){
this.setX(x);
this.setY(y);
}
public double getX(){
return this.x;
}
public double getY(){
return this.y;
}
public String toString(){
return "(" + this.getX() + " , " + this.getY() + ")";
}
public boolean equals(Punto p){
if(this.distance(p) == 0){
return true;
} else {
return false;
}
}
public double distance(Punto p){
return Math.sqrt(Math.pow(this.getX() - p.getX(), 2) + Math.pow(this.getY() - p.getY(),2));
}
public Punto middlePoint(Punto p){
Punto m = new Punto((this.getX() + p.getX())/2 , (this.getY() + p.getY())/2);
return m;
}
}