Skip to content

What is Cube2 and Cube3

Akshath Raghav edited this page Jun 28, 2021 · 1 revision
  • The Cubot(2/3) and Cube(2/3) classes have a composition relationship - Cubot(2/3) has-a Cube(2/3)
  • With an object of Cube(2/3) class, you can only make, compare with another Cube(2/3), and get the cubearray(String[][][][])
  • With an object of Cubot(2/3) class, you can do much more + what Cube3 can do

Below is the Cube class

  private String[][][][] cube ; 
  private int w = 0, g = 0, r = 0, o = 0, b = 0, y = 0;
  public Cube(2/3)(String  [] temp)  {} ; // Makes the Cube with String[]    

  public boolean solved(Cube(2/3) other) {} ; // tells you if its solved, with respect to another cube ( play around with it ;) )
  public String toString() {} ; // returns a String representing the cube
  public String indexString() {} ; // returns a String containing indexes of each piece
  public String[][][][] getCube()  {}; // returns the 4-D cube array
  public String[] cubeToArr() {} ; // returns a String[] in the input format
  • solved(Cube other) --> Returns true if Cube object matches another Cube object
String[] temp = {"RRRRRRRRR", "GGGGGGGGG", "OOOOOOOOO", "BBBBBBBBB", "WWWWWWWWW", "YYYYYYYYY"}; // for 3x3 
Cube3 cube1 = new Cube3(temp) ;
String[] temp2 = {"WGBOROGGY", "YOYWGBOYB", "RBBOORRBY", "OBGWBYRYR", "GRWRGYWGB", "OWWWYROGG"}; // for 3x3 
Cube3 cube2 = new Cube3(temp2) ; 
System.out.println(cube1.solved(cube2)) ; --> Returns false
  • toString/System.out.println --> Prints out the cube with indexes
String[] temp2 = {"RRRR", "GGGG", "OOOO", "BBBB", "WWWW", "YYYY"};
Cube2 cube = new Cube2(temp2) ;
System.out.println(cube);

example

  • indexString() --> returns a String containing indexes of each piece
String[] temp2 = {"RRRR", "GGGG", "OOOO", "BBBB", "WWWW", "YYYY"};
Cube2 cube = new Cube2(temp2) ;
System.out.println(cube.indexString());

example

  • getCube() --> Returns String[][][][] object containing the cubearray
String[] temp2 = {"RRRR", "GGGG", "OOOO", "BBBB", "WWWW", "YYYY"};
Cube2 cube = new Cube2(temp2) ;
String[][][][] cubearr = cube.getCube() ;
  • cubeToArr() --> returns a String[] in the input format
String[] temp2 = {"RRRR", "GGGG", "OOOO", "BBBB", "WWWW", "YYYY"};
Cube2 cube = new Cube2(temp2) ;
String[] cubeInput = cube.cubeToArr() ;
Clone this wiki locally