-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSquare.java
executable file
·49 lines (42 loc) · 1.18 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
public class Square{
public Thing t;
public boolean n,e,w,s;
public int locationX, locationY;
public boolean squareVisited;
public Square(boolean n,boolean e,boolean w, boolean s,int locationX, int locationY){
this.n = n;
this.e = e;
this.w = w;
this.s = s;
this.locationX = locationX;
this.locationY = locationY;
t = null;
squareVisited = false;
}
public String contains(){
if(t != null) return t.getType();
else return null;
}
public Thing getThing(){
return t;
}
public void setThing(Thing t){
this.t = t;
}
public void removeThing() {
this.t = null;
}
public void setWall(char wallToSet,boolean wallOrNoWall){
if(wallToSet == 'n') n = wallOrNoWall;
else if(wallToSet == 'e') e = wallOrNoWall;
else if(wallToSet == 'w') w = wallOrNoWall;
else if(wallToSet == 's') s = wallOrNoWall;
}
public void display() {
if(w == true) { System.out.print("| "); }
if(n == true && s == true) { System.out.print("-_");}
if(n == true && s == false) { System.out.print("--");}
if(n == false && s == true) { System.out.print("__");}
if(e == true) { System.out.print(" |"); }
}
}