开发者

Class method won't display results

For some reason class method getTime() won't output on the console screen the time. Where did I go wron开发者_开发百科g?


Your set methods have infinite loops!

private void setM(int minutes)
{
    while (minutes > 59)
    {
        h++;
        m = minutes - 60;
    }
}

When will this method stop?


The while loops in couple functions never return. Try

        private void setM(int minutes)
        {
            while (minutes > 59)
            {
                h++;
                minutes-=60;
            }
            m = minutes;
        }

and

       private void setS(int seconds)
        {
            while (seconds > 59)
            {
                m++;
                seconds-=60;
            }
            s = seconds;
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜