samedi 21 mars 2015

Using a loop to prevent infinite IF statements


}`public static void drawBorder() { // Asterisks based on wins
if (gameCount.asterisk == 0) {
System.out.println(" ");
}
if (gameCount.asterisk == 1) {
System.out.println("**********");
}
if (gameCount.asterisk == 2) {
System.out.println("********************");
}


}


How can I use a loop for this so it will print 10 asterisks multiplied by the value of gameCount.asterisk instead of using an unnecessary amount of if statements?


Aucun commentaire:

Enregistrer un commentaire