Skip to content

Instantly share code, notes, and snippets.

@ncovercash
Created April 7, 2017 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncovercash/22841e23714c91c23e521560a8b9c1c2 to your computer and use it in GitHub Desktop.
Save ncovercash/22841e23714c91c23e521560a8b9c1c2 to your computer and use it in GitHub Desktop.
public static String expandNumToDigits(int in, int digits) {
String stringIn = ""+in;
while (stringIn.length() < digits) {
stringIn = "0"+stringIn;
}
return stringIn;
}
public String toString() {
String str = "";
for (int row=0; row<list.length; row++) {
str += "[ ";
for (int col=0; col<list[row].length; col++) {
if (list[row][col] instanceof FilledRect) {
str += "FilledRect-"+expandNumToDigits(getTotalColorVals(list[row][col].getColor()), 3)+" "; // FilledRect-055 e.g.
} else if (list[row][col] instanceof FramedRect) {
str += "FramedRect-"+expandNumToDigits(getTotalColorVals(list[row][col].getColor()), 3)+" "; // FilledRect-055 e.g.
} else if (list[row][col] instanceof FilledOval) {
str += "FilledOval-"+expandNumToDigits(getTotalColorVals(list[row][col].getColor()), 3)+" "; // FilledRect-055 e.g.
} else {
str += "FramedOval-"+expandNumToDigits(getTotalColorVals(list[row][col].getColor()), 3)+" "; // FilledRect-055 e.g.
}
}
str += "]\n";
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment