Вам необходимо сделать count
переменной класса (членом) вашего класса контроллера и иметь цикл do / while в этом классе, чтобы startGuessingGame
обрабатывал только проверку выбора пользователя.Примерно так, но код далек от завершения
public class SomeControllerClass() {
final int attempts = 4;
int count = 0;
public void someMethod() {
int choice = 0;
do {
choice = getChoice();
count++;
String text = otherClass.startGuessingGame(choice, generatedNumber);
while (count < attempts);
}
и метод выполняет только проверку
public String startGuessingGame(int choice, int generatedNumber) {
String result = null;
if (choice == generatedNumber) {
result = "Attempt " + count + " "
+ "- You have guessed the correct number!";
} else if (choice > 50 || choice < 0) {
//and so on
return result;
}