Project

General

Profile

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

magiccube / src / main / java / org / distorted / patterns / RubikPatternList.java @ 6d4d56cb

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 1f9772f3 Leszek Koltunski
import org.distorted.objects.RubikObjectList;
23 b498f3f6 Leszek Koltunski
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
26
public enum RubikPatternList
27
  {
28
  CUBE2 (RubikObjectList.CUBE, 2, RubikPatternCube2.patterns),
29
  CUBE3 (RubikObjectList.CUBE, 3, RubikPatternCube3.patterns),
30
  CUBE4 (RubikObjectList.CUBE, 4, RubikPatternCube4.patterns),
31
  CUBE5 (RubikObjectList.CUBE, 5, RubikPatternCube5.patterns),
32 a46893d7 Leszek Koltunski
  PYRA3 (RubikObjectList.PYRA, 3, RubikPatternPyraminx3.patterns),
33 4a40166d Leszek Koltunski
  PYRA4 (RubikObjectList.PYRA, 4, RubikPatternPyraminx4.patterns),
34
  PYRA5 (RubikObjectList.PYRA, 5, RubikPatternPyraminx5.patterns),
35 b498f3f6 Leszek Koltunski
  ;
36
37
  public static final int NUM_OBJECTS = values().length;
38
  private RubikObjectList mObject;
39
  private int mSize;
40
  private String[][] mPatterns;
41
42
  private static final RubikPatternList[] objects;
43
44
  static
45
    {
46
    objects = new RubikPatternList[NUM_OBJECTS];
47
    int i=0;
48
49
    for(RubikPatternList object: RubikPatternList.values())
50
      {
51
      objects[i++] = object;
52
      }
53
    }
54
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56
57
  static String[][] getPatterns(int ordinal)
58
    {
59
    return objects[ordinal].mPatterns;
60
    }
61
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63
64
  RubikPatternList(RubikObjectList object, int size, String[][] patterns)
65
    {
66
    mObject   = object;
67
    mSize     = size;
68
    mPatterns = patterns;
69
    }
70
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72
// PUBLIC API
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74
75
  public static int getOrdinal(int objectOrdinal, int size)
76
    {
77
    for(int i=0; i<NUM_OBJECTS; i++)
78
      {
79
      if( objects[i].mObject.ordinal() == objectOrdinal && objects[i].mSize == size )
80
        {
81
        return i;
82
        }
83
      }
84
85
    return -1;
86
    }
87
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
90
  public static RubikObjectList getObject(int ordinal)
91
    {
92
    return objects[ordinal].mObject;
93
    }
94
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96
97
  public static int getSize(int ordinal)
98
    {
99
    return objects[ordinal].mSize;
100
    }
101
  }