コード例 #1
0
ファイル: Tempo.cs プロジェクト: SamuelQSouza/POO_2019-1
        public Tempo inc(Tempo t)
        {
            Tempo aux      = new Tempo();
            int   segundos = t.getSeg() + seg;
            int   minutos  = t.getMin() + min;
            int   horas    = t.getHor() + hor;

            if (segundos >= 60)
            {
                segundos = segundos - 60;
                minutos++;
            }
            if (minutos >= 60)
            {
                minutos = minutos - 60;
                horas++;
            }
            if (horas >= 24)
            {
                horas = horas - 24;
            }
            aux.setSeg(segundos);
            aux.setMin(minutos);
            aux.setHor(horas);
            return(aux);
        }
コード例 #2
0
ファイル: Tempo.cs プロジェクト: SamuelQSouza/POO_2019-1
        public Tempo dec(Tempo t)
        {
            Tempo aux      = new Tempo();
            int   segundos = t.getSeg() - seg;
            int   minutos  = t.getMin() - min;
            int   horas    = t.getHor() - hor;

            if (segundos < 0)
            {
                segundos = segundos * (-1);
            }
            if (minutos < 0)
            {
                minutos = minutos * (-1);
            }
            if (horas < 0)
            {
                horas = horas * (-1);
            }
            aux.setSeg(segundos);
            aux.setMin(minutos);
            aux.setHor(horas);
            return(aux);
        }