heres an easy trick for lining up strings:
String myLinedUpString = " " + myInt;
myLinedUpString = myLinedUpString.substring(myLinedUpString.length()-NUM_COLUMNS);
so if you want 3 columns, set NUM_COLUMNS to 3..
and youll get:
Code:
1
2 ...
10
11 ...
99 ...
100 ...
naturally that line of spaces " " must be at least as long as the number of columns, less one
heres how to print a table for an X x Y array:
Code:
method called horizontalRule()
//print the horizontal line
for as many counts as there are in array[x] dimension
print "+------"
//finish the lineheader
println "+"
method called cellDeadSpace()
//print the vertical bars and spaces
for as many counts as there are in array[x] dimension
print "| "
//finish the line
println "|"
method called printTable(array[x][y])
horizontalRule();
//print the data:
for each item in array[x]
cellDeadSpace()
print a line of data (for a fixed X, print the incremented Y values)
cellDeadSPace()
horizontalRule()
increment x
loop until x is exhausted
now, just write the code
Bookmarks