在我的表格顶部,我有:
public static int hoursInt;
public static int minutesInt;
public static int secondsInt;
public static int CompletedIn24;
numericUpDown
然后再往下,在选择新跑步者时,我有以下内容将框重置为零:
private void lstRunners_SelectedIndexChanged(object sender, EventArgs e)
{
Runner selectedRunner = (Runner)lstRunners.SelectedItem;
numericUpDown1.Value = 0;
numericUpDown2.Value = 0;
numericUpDown3.Value = 0;
}
然后在Finish
按钮单击事件中我有:
hoursInt = Convert.ToInt32(numericUpDown1.Value);
minutesInt = Convert.ToInt32(numericUpDown2.Value);
secondsInt = Convert.ToInt32(numericUpDown3.Value);
if (lstRunners.SelectedIndex > -1 && hoursInt + minutesInt + secondsInt != 0)
{
// Obtain selected climber
Runner selectedRunner = (Runner)lstRunners.SelectedItem;
selectedRunner.Hours = hoursInt;
selectedRunner.Minutes = minutesInt;
selectedRunner.Seconds = secondsInt;
var expertRunner = selectedRunner as Expert;
if (expertRunner != null)
{
expertRunner.UponFinish();
}
这是我的重写方法Expert : Runner
:
public override void UponFinish()
{
base.UponFinish();
// The integer must increment by one if the time is 24:00:00 or less i.e. 23:59:59 would increment the integer as well
if (Hours < 24 || (Hours == 24 && Minutes == 0 && Seconds == 0))
{
CompletedIn24++;
}
}
目前,UponFinish()
方法 inRunner
大括号内没有任何东西,因为我不确定是否需要任何东西?
我尝试将CompletedIn24
整数输出到字符串,以查看单击按钮时它是否可以工作,但即使选择了专家赛跑者并且时间为 24:00:00 或更短,该值仍保持为零。整数没有增加,我不确定是什么导致了问题?
任何帮助,将不胜感激。