Skip to main content
added 8 characters in body
Source Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

This code in makePhrase() should be a switch block:

if (phraseType == 1) {
    ...
} else if (phraseType == 2) {
    ...
} else if (phraseType == 3) {
    ...
}

Within the phraseType == 2 case, your switch is buggy: all cases flow through to correctPhrase = phraseThree.clone().

The cascading if-elses in drawBoard() should also be put into a switch. Better yet, there should be an array with all of the images, then you could index into the array:

private static final String[] IMAGES = {
    // Initial:
    "\n______" +
    "\n|    |" +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     ",

    // 1 wrong:
    "\n______" +
    "\n|    |" +
    "\n|    O" +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     ",

    // etc.

    // 6 wrong:
    "\n______" +
    "\n|    |" +
    "\n|    O" +
    "\n|   -|-" +
    "\n|   / \\" +
    "\n|     " +
    "\n|     " +
    "\n\n YOU DIED!"
};

Then it's just System.out.print(totalWrongIMAGES[totalWrong]);.

This code in makePhrase() should be a switch block:

if (phraseType == 1) {
    ...
} else if (phraseType == 2) {
    ...
} else if (phraseType == 3) {
    ...
}

Within the phraseType == 2 case, your switch is buggy: all cases flow through to correctPhrase = phraseThree.clone().

The cascading if-elses in drawBoard() should also be put into a switch. Better yet, there should be an array with all of the images, then you could index into the array:

private static final String[] IMAGES = {
    // Initial:
    "\n______" +
    "\n|    |" +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     ",

    // 1 wrong:
    "\n______" +
    "\n|    |" +
    "\n|    O" +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     ",

    // etc.

    // 6 wrong:
    "\n______" +
    "\n|    |" +
    "\n|    O" +
    "\n|   -|-" +
    "\n|   / \\" +
    "\n|     " +
    "\n|     " +
    "\n\n YOU DIED!"
};

Then it's just System.out.print(totalWrong);.

This code in makePhrase() should be a switch block:

if (phraseType == 1) {
    ...
} else if (phraseType == 2) {
    ...
} else if (phraseType == 3) {
    ...
}

Within the phraseType == 2 case, your switch is buggy: all cases flow through to correctPhrase = phraseThree.clone().

The cascading if-elses in drawBoard() should also be put into a switch. Better yet, there should be an array with all of the images, then you could index into the array:

private static final String[] IMAGES = {
    // Initial:
    "\n______" +
    "\n|    |" +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     ",

    // 1 wrong:
    "\n______" +
    "\n|    |" +
    "\n|    O" +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     ",

    // etc.

    // 6 wrong:
    "\n______" +
    "\n|    |" +
    "\n|    O" +
    "\n|   -|-" +
    "\n|   / \\" +
    "\n|     " +
    "\n|     " +
    "\n\n YOU DIED!"
};

Then it's just System.out.print(IMAGES[totalWrong]);.

Source Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

This code in makePhrase() should be a switch block:

if (phraseType == 1) {
    ...
} else if (phraseType == 2) {
    ...
} else if (phraseType == 3) {
    ...
}

Within the phraseType == 2 case, your switch is buggy: all cases flow through to correctPhrase = phraseThree.clone().

The cascading if-elses in drawBoard() should also be put into a switch. Better yet, there should be an array with all of the images, then you could index into the array:

private static final String[] IMAGES = {
    // Initial:
    "\n______" +
    "\n|    |" +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     ",

    // 1 wrong:
    "\n______" +
    "\n|    |" +
    "\n|    O" +
    "\n|     " +
    "\n|     " +
    "\n|     " +
    "\n|     ",

    // etc.

    // 6 wrong:
    "\n______" +
    "\n|    |" +
    "\n|    O" +
    "\n|   -|-" +
    "\n|   / \\" +
    "\n|     " +
    "\n|     " +
    "\n\n YOU DIED!"
};

Then it's just System.out.print(totalWrong);.