reset password
Author Message
khsu
Posts: 30
Posted 15:16 Feb 22, 2014 |

I finished my program, however there is something I am not quite sure about.

In the template for GameEngine


 
public class GameEngine {
public static void clearConsole() {
// clear the console so that other player
// cannot see your input
for (int i = 0; i < 50; i ++) {
System.out.println();
}
}

how would I use this method to clear the console?

Note that I did not use all the code provided from the template, you may need to take a look at my code, it is uploaded.

Eric Liao
Posts: 158
Posted 15:34 Feb 22, 2014 |

The point of having clearConsole() method is to clear the console screen so that player 2 has no idea what player 1 put.

Assume you want to play this simple application with your friend/classmate how can you stop them from knowing your bid? One simple way to do it is to print a lot of empty line so that your bid will not be on the screen anymore. Eventually, on the same computer/device, two player will not be able to know the bid of each other.

khsu
Posts: 30
Posted 16:01 Feb 22, 2014 |

I see. I was wondering why we would want to print 50 empty lines.

I have went back and adjusted my code, thanks.

Last edited by khsu at 16:02 Feb 22, 2014.
kknaur
Posts: 540
Posted 17:57 Feb 22, 2014 |

Hmm, well...if you guys REALLY want to clear the console...check out this post on StackOverflow ^_^

http://stackoverflow.com/questions/2979383/java-clear-the-console

Never too soon to start experimenting with more advanced techniques!

Last edited by kknaur at 17:59 Feb 22, 2014.