コード例 #1
0
        /*   item f)    */

        public Tempo Subtrai_Tempo(Tempo tempo)
        {
            Tempo t = new Tempo();

            t.setHora(hora - tempo.getHora());
            t.setMin(min - tempo.getMin());
            t.setSeg(seg - tempo.getSeg());

            if (t.seg < 0)
            {
                t.seg = (60 + t.seg);
                t.min--;
            }
            if (t.min < 0)
            {
                t.min = (60 + t.min);
                t.hora--;
            }

            return(t);
        }
コード例 #2
0
        /*   item e)    */

        public Tempo Adiciona_Tempo(Tempo tempo)
        {
            Tempo t = new Tempo();

            t.setHora(hora + tempo.getHora());
            t.setMin(min + tempo.getMin());
            t.setSeg(seg + tempo.getSeg());

            if (t.seg >= 60)
            {
                t.seg = (t.seg - 60);
                t.min++;
            }
            if (t.min >= 60)
            {
                t.min = (t.min - 60);
                t.hora++;
            }

            return(t);
        }