2014-12-26 6 views
-1

나는 타이머를 만들고 있는데, 1 초 카운트 다운을 준비하는 5 초가있다. 그런 다음 (작업 시간과 휴식 시간)을 8 번 반복 한 다음 끝내야한다. 작업과 휴식의 조합이 제한되어있는 경우,타이머 루핑 기능

if(prepTicks <= 5) {} 
    else if (workTick <= 8) {} 
    else if (restTicks <= 8) {} 
    else {} 

또는 : 분에서 그냥 다음은 각 타이머

if(prepTicks>0) 
{ 
    txtblPrepare.Visibility = System.Windows.Visibility.Visible; 
    txtblGo.Visibility = System.Windows.Visibility.Collapsed; 
    txtblTime.Text = prepTicks + " Seconds Remaining"; 
    prepTicks--;    
} 
else if (workTick > 0) 
{ 
    txtblPrepare.Visibility = System.Windows.Visibility.Collapsed; 
    txtblGo.Visibility = System.Windows.Visibility.Visible; 
    txtblTime.Text = workTick + " Seconds Remaining"; 
    workTick--; 
} 
else if (restTicks > 0) 
{ 
    txtblGo.Visibility = System.Windows.Visibility.Collapsed; 
    txtblRest.Visibility = System.Windows.Visibility.Visible; 
    txtblTime.Text = restTicks + " Seconds Remaining"; 
    restTicks--; 
} 
else 
{ 
    txtblRest.Text = "Congratulations"; 
    txtblTime.Text = "Times Up"; 
} 
+0

5 초 및 8 시간 동안 상태가 없습니다. – MikeG

+0

나는 (작업 타이머 + 휴식 타이머) 8 번, 모든 'for (rounds = 0; rounds <9; rounds ++) {나머지 타이머보다 작업 타이머를 수행}}' –

답변

1

카운트 다운 증가 틱과 접근 방법이다

if(prepTicks <= 5) {} 
    else if (workTick + restTicks <= 8 && restTicks > workTick) {} // altermating work and rest 
    else if (restTicks + workTick <= 8) {} 
    else {} 

또한이 예제에서는 증분 틱이 예상되므로 남은 시간을 다시 계산하는 것을 잊지 마십시오.