Revision 20931cf6
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/objects/RubikObjectList.java | ||
---|---|---|
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
import org.distorted.main.R; |
27 | 27 |
|
28 |
import java.lang.reflect.Field; |
|
29 |
|
|
28 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
29 | 31 |
|
30 | 32 |
public enum RubikObjectList |
... | ... | |
36 | 38 |
{4 , R.drawable.cube4} , |
37 | 39 |
{5 , R.drawable.cube5} |
38 | 40 |
}, |
41 |
RubikCube.class, |
|
39 | 42 |
new RubikCubeMovement() |
40 | 43 |
), |
41 | 44 |
|
... | ... | |
45 | 48 |
{4 , R.drawable.pyra4} , |
46 | 49 |
{5 , R.drawable.pyra5} |
47 | 50 |
}, |
51 |
RubikPyraminx.class, |
|
48 | 52 |
new RubikPyraminxMovement() |
49 | 53 |
), |
50 | 54 |
; |
... | ... | |
53 | 57 |
public static final int MAX_SIZE; |
54 | 58 |
|
55 | 59 |
private final int[] mObjectSizes, mIconIDs; |
56 |
final RubikObjectMovement mObjectMovementClass; |
|
60 |
private final Class<? extends RubikObject> mObjectClass; |
|
61 |
private final RubikObjectMovement mObjectMovementClass; |
|
57 | 62 |
private static final RubikObjectList[] objects; |
58 | 63 |
private static int mNumAll; |
59 | 64 |
|
... | ... | |
213 | 218 |
|
214 | 219 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
215 | 220 |
|
216 |
RubikObjectList(int[][] info, RubikObjectMovement movement) |
|
221 |
public static int[] retFaceColors(RubikObjectList object) |
|
222 |
{ |
|
223 |
Field field; |
|
224 |
int[] faceColors=null; |
|
225 |
|
|
226 |
try |
|
227 |
{ |
|
228 |
field = object.mObjectClass.getDeclaredField("FACE_COLORS"); |
|
229 |
field.setAccessible(true); |
|
230 |
Object obj = field.get(null); |
|
231 |
faceColors = (int[]) obj; |
|
232 |
} |
|
233 |
catch(NoSuchFieldException ex) |
|
234 |
{ |
|
235 |
android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": no such field exception getting field: "+ex.getMessage()); |
|
236 |
} |
|
237 |
catch(IllegalAccessException ex) |
|
238 |
{ |
|
239 |
android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": illegal access exception getting field: "+ex.getMessage()); |
|
240 |
} |
|
241 |
|
|
242 |
return faceColors; |
|
243 |
} |
|
244 |
|
|
245 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
246 |
|
|
247 |
RubikObjectList(int[][] info, Class<? extends RubikObject> object , RubikObjectMovement movement) |
|
217 | 248 |
{ |
218 | 249 |
int length = info.length; |
219 | 250 |
|
... | ... | |
226 | 257 |
mIconIDs[i] = info[i][1]; |
227 | 258 |
} |
228 | 259 |
|
260 |
mObjectClass = object; |
|
229 | 261 |
mObjectMovementClass = movement; |
230 | 262 |
} |
231 | 263 |
|
Also available in: Unified diff
Progress making the Solver state more abstract.