2013-03-08 3 views
0

У меня есть программа, которая записывает результаты игроков в гольф, но когда их счет равен -1, значит, они обманули, и ему не нужно записывать их счет/имя.Остановка программы от записи строки

У меня есть все, кроме кода, необходимого для того, чтобы НЕ сохранить свои баллы/имена.

do { 
      score = input2.nextInt(); 
      total = score + total; 
      shotCount++; 

      //if score is -1 cut the player out 
      if (score == -1) { 
       shotCount = holesPlayed; 
       drop = 1; 
      } 
      if (drop == 1) { 
       //THIS IS WHERE THE PROBLEM IS. 
       //it needs to stop the scores from being recorded 
       //in the if statements below.          
      } 

      //to save players lowest (best) shot 
      if (score < bestShot) { 
       bestShot = score; 
       lowestFirstName = firstName; 
       lowestLastName = lastName; 
      } 
      //to save players highest (worst) shot 
      if (score > worstShot) { 
       worstShot = score; 
       highestFirstName = firstName; 
       highestLastName = lastName; 
      } 
     } while (shotCount < holesPlayed); 
+0

Какой язык это? Ява? – Blender

ответ

0

Вы можете использовать continue ключевое слово, чтобы пропустить текущую итерацию цикла:

if (score == -1) { 
    shotCount = holesPlayed; 
    continue; 
}