JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Map;
import java.util.HashMap;
import java.util.Vector;
import java.util.Random;
public class Cube {
// here is declared the 8 letters that each cube contains at each vertex
private char[] letters = new char[8];
// these are the rotation codes. I decided to order them in the letters array above 0 - 7. In order to display them in that order, you
// need to know where the positions of the verteces of the cube correspond to the positions in the array. Look below in the Cube constructor to learn how.
private Map<Integer, Integer> right = new HashMap<Integer, Integer>();
private Map<Integer, Integer> left = new HashMap<Integer, Integer>();
private Map<Integer, Integer> up = new HashMap<Integer, Integer>();
private Map<Integer, Integer> down = new HashMap<Integer, Integer>();
// this is where I store the rotation sequence for each cube. It is initiallized with random rotations in the constructor below
// private Vector rotationSequence = new Vector();
private Vector<Integer> rotationSequence = new Vector<Integer>();
// show the cube
public void show() {
System.out.println(" " + letters[5] + "----" + letters[6]);
System.out.println(" /| /|");
System.out.println(letters[1] + "----" + letters[2] + " |");
System.out.println("| " + letters[4] + " | " + letters[7]);
System.out.println("|/ |/ ");
System.out.println(letters[0] + "----" + letters[3] + " ");
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run