Andy Hammersmith wrote:I am making a class that will print out the array 'boxcount' to print out from 0 to the nth power. I am not sure how to get it to print out all of them.
So you don't know how to print out each element of an array?
Is it that you don't know how to do something with each element of an array?
Or is it that you don't know how to print something out?
Because those are the only two things you need to know in order to print out each element of an array, and I see the first is already in your code. Although I don't see the second one there, if this is not your very first Java program ever, you've almost certainly done it (think "Hello World"), so it's not clear to me where your problem lies.
Andy Hammersmith wrote:
public String toString()
String dummy = "";
dummy = dummy + " Probability | Galton Board \n";
dummy = dummy + "------------------------------------\n";
dummy = dummy + " " + /*I dont know what to put here*/;
Put nothing there. Scrap the method entirely. Output on a line by line basis after the data is generated in the board() method. Use System.out.println() to output and forget concatenating a giant string.
The header to all that can be printed with println() ONCE at the beginning of execution very easily, even in main() to insure it only executes once.
Another suggestion is to call board() so that it will execute. Since there is no call to that method it simply cannot run.
This class will do nothing as a stand-alone class. Nothing at all that I can see. There are methods with no method calls. There is no main().
Or is it not stand alone? There is no way we can see what you're not showing us or describing to us.