-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlaceHolder.java
229 lines (168 loc) · 4.3 KB
/
PlaceHolder.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import java.util.Arrays;
import java.util.HashSet;
/**
*
*/
/**
* @author Mayank
* Implementation of PlaceHolder cell i.e all the spaces which are potential to contains the words of the puzzle
*/
public class PlaceHolder {
/**
* @ startPoint : start point of the placeholder (x and y coordinate)
* @ size : size of the placeholder :length of the word it can contain
* @ direction : Direction of the placeHolder i.e either horizontal or vertical
* @ value : Value it will contain
* @ possibleWordslist : Potential set of word which can be placed in the placeholder
* length of the word = sixe of the placeholder
*/
private GridPoint startPoint;
private int size;
private Character orientation;
private Character[] value ;
private HashSet<String> possibleWordslist;
/**
*
*/
public PlaceHolder() {
// TODO Auto-generated constructor stub
}
/**
* @param startPoint
* @param size
* @param direction
* @param value
* @param possibleWordslist
*/
public PlaceHolder(GridPoint startPoint, int size, char direction, Character[] value,
HashSet<String> possibleWordslist) {
super();
this.startPoint = startPoint;
this.size = size;
this.orientation = direction;
this.possibleWordslist = possibleWordslist;
}
/**
* @param startPoint
* @param size
* @param direction
*/
public PlaceHolder(GridPoint startPoint, int size, char direction) {
super();
this.startPoint = startPoint;
this.size = size;
this.orientation = direction;
this.value = new Character[this.size];
Arrays.fill(value, ' ');
this.possibleWordslist = new HashSet<String>();
}
/**
* @return the startPoint
*/
public GridPoint getStartPoint() {
return startPoint;
}
/**
* @param startPoint the startPoint to set
*/
public void setStartPoint(GridPoint startPoint) {
this.startPoint = startPoint;
}
/**
* @return the size
*/
public int getSize() {
return size;
}
/**
* @param size the size to set
*/
public void setSize(int size) {
this.size = size;
}
/**
* @return the direction
*/
public char getOrientation() {
return orientation;
}
/**
* @param direction the direction to set
*/
public void setOrientation(char orientation) {
this.orientation = orientation;
}
/**
* @return the value
*/
public Character[] getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Character[] value) {
this.value = value;
}
/**
* @return the possibleWordslist
*/
public HashSet<String> getPossibleWordslist() {
return possibleWordslist;
}
/**
* @param possibleWordslist the possibleWordslist to set
*/
public void setPossibleWordslist(HashSet<String> possibleWordslist) {
this.possibleWordslist = possibleWordslist;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((orientation == null) ? 0 : orientation.hashCode());
result = prime * result + ((possibleWordslist == null) ? 0 : possibleWordslist.hashCode());
result = prime * result + size;
result = prime * result + ((startPoint == null) ? 0 : startPoint.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PlaceHolder other = (PlaceHolder) obj;
if (orientation == null) {
if (other.orientation != null)
return false;
} else if (!orientation.equals(other.orientation))
return false;
if (possibleWordslist == null) {
if (other.possibleWordslist != null)
return false;
} else if (!possibleWordslist.equals(other.possibleWordslist))
return false;
if (size != other.size)
return false;
if (startPoint == null) {
if (other.startPoint != null)
return false;
} else if (!startPoint.equals(other.startPoint))
return false;
if (value == null) {
if (other.value != null)
return false;
} else if (!value.equals(other.value))
return false;
return true;
}
@Override
public String toString() {
return "PlaceHolder [startPoint=" + startPoint + ", size=" + size + ", direction=" + orientation + ", value="
+ value + ", possibleWordslist=" + possibleWordslist + "]";
}
}