Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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