-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSquare.java
91 lines (74 loc) · 1.83 KB
/
Square.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
package com.example.manju.shapes;
public class Square {
private int left;
private int top;
private int right;
private int bottom;
private int screenY = 1800;
public Square(int left, int top, int right, int bottom){
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
public int getLeft(){
return left;
}
public int getRight(){
return right;
}
public int getBottom(){
return bottom;
}
public int getTop(){
return top;
}
public void moveNorth() {
if (bottom <= (1000)) {
top = top + 5;
bottom = bottom + 5;
}
if (bottom >= (1000)) {
top = top - screenY - 5;
bottom = bottom - screenY - 5;
}
}
public void moveSouth() {
int length = right - left;
if(bottom >=0) {
top = top - 10;
bottom = bottom - 10;
}
if(bottom<0){
bottom = 1000;
top = bottom -length;
}
// left = left - 10;
//right = right -10;
}
public void moveEast() {
int length = bottom - top;
if (right >= 0) {
left = left - 10;
right = right - 10;
}
if (right < 0) {
right = 1000;
left = right - length;
}
}
public void moveWest() {
int length = bottom - top;
if(right <=1800) {
left = left +5;
right = right + 5;
}
if(right>=1800){
right = 0;
left = right + length;
right = right + 5;
}
// left = left - 10;
//right = right -10;
}
}