-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBirResmiKodlamakClassCizgiOlusturma.java
114 lines (88 loc) · 2.15 KB
/
BirResmiKodlamakClassCizgiOlusturma.java
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package BirGörseliKodlamak;
public class Line {
private Point begin, end;
//parameters constructor
public Line(int x1, int y1, int x2, int y2) {
this.begin = new Point(x1, y1);
this.end = new Point(x2, y2);
}
//point value constructor
public Line(Point firstPoint, Point lastPoint) {
this.begin = new Point(firstPoint.getX(), firstPoint.getY());
this.end = new Point(lastPoint.getX(), lastPoint.getY());
}
//setter & getter
public Point getBegin() {
return this.begin;
}
public Point getEnd() {
return this.end;
}
public void setBegin(Point firstPoint) {
this.begin.setX(firstPoint.getX());
this.begin.setY(firstPoint.getY());
}
public void setEnd(Point lastPoint) {
this.end.setX(lastPoint.getX());
this.end.setY(lastPoint.getY());
}
//get set begin & get set end
public int getBeginX() {
return this.begin.getX();
}
public int getBeginY() {
return this.begin.getY();
}
public int getEndX() {
return this.end.getX();
}
public int getEndY() {
return this.end.getY();
}
public void setBeginX(int x) {
this.begin.setX(x);
}
public void setBeginY(int y) {
this.begin.setY(y);
}
public void setEndX(int x) {
this.end.setX(x);
}
public void setEndY(int y) {
this.end.setY(y);
}
//getBeginXY:int[2] method
public int[] getBeginXY() {
int[] pointArr = new int[2];
pointArr[0] = this.getBeginX();
pointArr[1] = this.getBeginY();
return pointArr;
}
//getEndXY:int[2] method
public int[] getEndXY() {
int[] pointArr = new int[2];
pointArr[0] = this.getEndX();
pointArr[1] = this.getEndY();
return pointArr;
}
//setBeginXY(x:int, y:int):void method
public void setBeginXY(int x, int y) {
this.begin.setX(x);
this.begin.setY(y);
}
//setBeginXY(x:int, y:int):void method
public void setEndXY(int x, int y) {
this.end.setX(x);
this.end.setY(y);
}
//toString() method
public String toString() {
return "'Line[begin=(" + this.getBeginX() + ", " + this.getBeginY() + "), end=(" +
this.getEndX() + ", " + this.getEndY() + ")]'";
}
//getLength():double
public double getLength() {
double result = begin.distance(end);
return result;
}
}