Originally posted by: Onund
so wait, you have to recreate that checkerboard pattern but the three print statements can only appear in your program once? mundane is right, you have to put your print("###...") and print(" ") in different loops...
or if you want to piss off whoever marks this, and you are allowed to use function calls you can do something horribly mean like this:
public void f(){
System.out.print(" ")
}
public void u(){
System.out.print("########");
}
public void man(){
System.out.print("\n");
}
public static void main(String[] args){
f();
f();
f();
f();
f();
f();
f();
f();
u();
f();
f();
...
}
but really, stick to fixing up your loops.
lol!!! I liked that one.
I would say it is all about making a few function calls so that you only have the "System.out.print" things in there once, just like the above example did. Your instructor's rules said you can only do it once in the program, and this is the way to do it. Then you might want to create some extra functions like
public void w() {
for(int i=0; i<6;i++ {
f();
}
}
public void print_white_black_line() {
w();
u();
w();
u();
w();
u();
w();
u();
f();
new_line_character();
}
public void print_black_white_line() {
u();
w();
u();
w();
u();
w();
u();
w();
new_line_character();
}
public void print white_black_checker() {
print_white_black_line();
print_white_black_line();
print_white_black_line();
print_white_black_line();
}
public void print black_white_checker() {
print_black_white_line();
print_black_white_line();
print_black_white_line();
print_black_white_line();
}
etc...etc... etc...
Basically you can call the functions whatever you want. Making it logical will probably score more points for style. And you can keep building on the functions until you have a final single function and just have "main" call that one function.