Project

General

Profile

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

magiccube / src / main / java / org / distorted / patterns / RubikPatternList.java @ b498f3f6

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import org.distorted.object.RubikObjectList;
23

    
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
  ;
33

    
34
  public static final int NUM_OBJECTS = values().length;
35
  private RubikObjectList mObject;
36
  private int mSize;
37
  private String[][] mPatterns;
38

    
39
  private static final RubikPatternList[] objects;
40

    
41
  static
42
    {
43
    objects = new RubikPatternList[NUM_OBJECTS];
44
    int i=0;
45

    
46
    for(RubikPatternList object: RubikPatternList.values())
47
      {
48
      objects[i++] = object;
49
      }
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  static RubikPatternList[] getPatterns()
55
    {
56
    return objects;
57
    }
58

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

    
61
  static String[][] getPatterns(int ordinal)
62
    {
63
    return objects[ordinal].mPatterns;
64
    }
65

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

    
68
  RubikPatternList(RubikObjectList object, int size, String[][] patterns)
69
    {
70
    mObject   = object;
71
    mSize     = size;
72
    mPatterns = patterns;
73
    }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76
// PUBLIC API
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78

    
79
  public static int getOrdinal(int objectOrdinal, int size)
80
    {
81
    for(int i=0; i<NUM_OBJECTS; i++)
82
      {
83
      if( objects[i].mObject.ordinal() == objectOrdinal && objects[i].mSize == size )
84
        {
85
        return i;
86
        }
87
      }
88

    
89
    return -1;
90
    }
91

    
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

    
94
  public static RubikObjectList getObject(int ordinal)
95
    {
96
    return objects[ordinal].mObject;
97
    }
98

    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100

    
101
  public static int getSize(int ordinal)
102
    {
103
    return objects[ordinal].mSize;
104
    }
105
  }
(6-6/6)