Project

General

Profile

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

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

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 String[][] getPatterns(int ordinal)
55
    {
56
    return objects[ordinal].mPatterns;
57
    }
58

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

    
61
  RubikPatternList(RubikObjectList object, int size, String[][] patterns)
62
    {
63
    mObject   = object;
64
    mSize     = size;
65
    mPatterns = patterns;
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69
// PUBLIC API
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

    
72
  public static int getOrdinal(int objectOrdinal, int size)
73
    {
74
    for(int i=0; i<NUM_OBJECTS; i++)
75
      {
76
      if( objects[i].mObject.ordinal() == objectOrdinal && objects[i].mSize == size )
77
        {
78
        return i;
79
        }
80
      }
81

    
82
    return -1;
83
    }
84

    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86

    
87
  public static RubikObjectList getObject(int ordinal)
88
    {
89
    return objects[ordinal].mObject;
90
    }
91

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

    
94
  public static int getSize(int ordinal)
95
    {
96
    return objects[ordinal].mSize;
97
    }
98
  }
(6-6/6)