开发者

Class method won't display results

开发者 https://www.devze.com 2023-02-17 17:30 出处:网络
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!

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

精彩评论

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