Skip to content

Comparing Cubots

Akshath Raghav edited this page Jun 28, 2021 · 2 revisions

compareTo(Cubot other)

--> returns true if this and other have the same Cubot

  • if this and other have different cubeTypes, an IllegalArgumentException is thrown
Cubot cube = new Cubot();
Cubot cube2 = new Cubot() ;
System.out.println("Same Cube? -- " + cube.compareTo(cube2)) ;
// -- true 

Cubot cube = new Cubot();
String[] end2  = {"RRRR", "GGGG", "OOOO", "BBBB", "WWWW", "YYYY"};
Cubot cube2 = new Cubot(temp2) ;
System.out.println("Same Cube? -- " + cube.compareTo(cube2)) ;
// -- Exception in thread "main" java.lang.IllegalArgumentException: Error: Unmatched cubeTypes
//	at Cubot.compareTo(Cubot.java:134)

You can also do this manually if you wish to.

  • getCube() returns the Cube object ( it can be Cube2 or Cube3 -- exceptions shouldn't go unhandled )
  • solved() is a Cube(2/3) method
Cubot cube = new Cubot();
Cubot cube2 = new Cubot() ; 
System.out.println(((Cube3) cube.getCube()).solved((Cube3) cube2.getCube())) ;
// -- true 
Clone this wiki locally