public LinkedList<String> getValueNames() { LinkedList<String> valueNames = new LinkedList<String>(); for (Value v : values) valueNames.add(v.getContent()); return valueNames; }
public void printValues() { if (isMagicSquare) { System.out.println("Printing magic square:"); int totalValues = values.size(); int n = (int) Math.sqrt(totalValues); int count = 0; for (Value v : values) { ++count; System.out.print(v.getValue() + "\t"); if (count >= n) { count = 0; System.out.println(""); } } } else { int n = values.size(); int[] heights = new int[n]; String toPrint = "\n"; for (int i = 0; i < n; i++) { heights[i] = Integer.valueOf(values.get(i).getValue()); } for (int i = 0; i < n; i++) { int maxValueIndex = getMax(heights); for (int j = 0; j < maxValueIndex; j++) { toPrint += " O "; } int xToAdd = n - maxValueIndex - 1; toPrint += " X "; for (int j = 0; j < xToAdd; j++) { toPrint += " O "; } toPrint += "\n"; heights[maxValueIndex] = -1; } System.out.println(toPrint); for (Value v : values) { System.out.print(v.getContent() + ": " + v.getValue() + " "); } System.out.println(""); } }