Project

General

Profile

Download (4.15 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / patterns / RubikPatternList.java @ 3f7a4363

1 b498f3f6 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.patterns;
21
22 3f7a4363 Leszek Koltunski
import org.distorted.objectlib.main.ObjectList;
23 b498f3f6 Leszek Koltunski
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
26
public enum RubikPatternList
27
  {
28 234a7582 Leszek Koltunski
  CUBE2 (ObjectList.CUBE, 2, PatternCube2.patterns),
29
  CUBE3 (ObjectList.CUBE, 3, PatternCube3.patterns),
30
  CUBE4 (ObjectList.CUBE, 4, PatternCube4.patterns),
31
  CUBE5 (ObjectList.CUBE, 5, PatternCube5.patterns),
32
  PYRA3 (ObjectList.PYRA, 3, PatternPyraminx3.patterns),
33
  PYRA4 (ObjectList.PYRA, 4, PatternPyraminx4.patterns),
34
  PYRA5 (ObjectList.PYRA, 5, PatternPyraminx5.patterns),
35 3c4495ac Leszek Koltunski
  MEGA3 (ObjectList.MEGA, 3, PatternMegaminx.patterns),
36 f185faf8 Leszek Koltunski
  MEGA5 (ObjectList.MEGA, 5, PatternGigaminx.patterns),
37 b498f3f6 Leszek Koltunski
  ;
38
39
  public static final int NUM_OBJECTS = values().length;
40 3c4495ac Leszek Koltunski
  private final ObjectList mObject;
41
  private final int mSize;
42
  private final String[][] mPatterns;
43 b498f3f6 Leszek Koltunski
44
  private static final RubikPatternList[] objects;
45
46
  static
47
    {
48
    objects = new RubikPatternList[NUM_OBJECTS];
49
    int i=0;
50
51
    for(RubikPatternList object: RubikPatternList.values())
52
      {
53
      objects[i++] = object;
54
      }
55
    }
56
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58
59
  static String[][] getPatterns(int ordinal)
60
    {
61
    return objects[ordinal].mPatterns;
62
    }
63
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65
66 9c2f0c91 Leszek Koltunski
  RubikPatternList(ObjectList object, int size, String[][] patterns)
67 b498f3f6 Leszek Koltunski
    {
68
    mObject   = object;
69
    mSize     = size;
70
    mPatterns = patterns;
71
    }
72
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74
// PUBLIC API
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76
77
  public static int getOrdinal(int objectOrdinal, int size)
78
    {
79
    for(int i=0; i<NUM_OBJECTS; i++)
80
      {
81
      if( objects[i].mObject.ordinal() == objectOrdinal && objects[i].mSize == size )
82
        {
83
        return i;
84
        }
85
      }
86
87
    return -1;
88
    }
89
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91
92 9c2f0c91 Leszek Koltunski
  public static ObjectList getObject(int ordinal)
93 b498f3f6 Leszek Koltunski
    {
94
    return objects[ordinal].mObject;
95
    }
96
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98
99
  public static int getSize(int ordinal)
100
    {
101
    return objects[ordinal].mSize;
102
    }
103
  }