Ejemplo n.º 1
0
 //construtores
 public Estacionamento()
 {
     chapa   = null;
     placa   = null;
     entrada = new Tempo();
     saida   = new Tempo();
 }
Ejemplo n.º 2
0
        public Tempo Soma(Tempo t1, Tempo t2)
        {
            int h, m, s;

            h = t1.hora + t2.hora;
            m = t1.min + t2.min;
            s = t1.seg + t2.seg;
            if (s >= 60)
            {
                s -= 60;
                m++;
            }
            if (m >= 60)
            {
                s -= 60;
                h++;
            }
            if (h >= 24)
            {
                h -= 24;
            }
            Tempo t3 = new Tempo(h, m, s);

            return(t3);
        }
Ejemplo n.º 3
0
        public float preço()
        {
            float preço;
            Tempo t = saida.Sub(saida, entrada);
            float s = t.modulo(t);

            preço = (s * 7);
            return(preço);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            float preço;
            //teste classe tempo
            Tempo tempo1 = new Tempo();
            Tempo tempo2 = new Tempo();
            Tempo tempo3 = new Tempo();
            Tempo tempo4 = new Tempo();

            tempo1.NovoHorario();
            tempo2.NovoHorario();
            tempo3 = tempo1.Soma(tempo1, tempo2);
            tempo4 = tempo1.Sub(tempo1, tempo2);
            tempo1.Imprime();
            tempo2.Imprime();
            tempo3.Imprime();
            tempo4.Imprime();
            //teste classe estacionamento

            Estacionamento veic1 = new Estacionamento();

            veic1.cadastro();
            veic1.mostrar();
            veic1.preço();
            //teste matriz
            Console.Write("\n Cadastrar matriz de 5 carros\n");
            List <Estacionamento> listaCarro = new List <Estacionamento>();

            for (int i = 0; i < 5; i++)
            {
                Estacionamento car = new Estacionamento();
                Console.WriteLine("Carro " + (i + 1) + ":\n");
                car.cadastro();
                listaCarro.Add(car);
            }
            for (int i = 0; i < listaCarro.Count; i++)
            {
                Estacionamento aux = (Estacionamento)listaCarro[i];
                Console.WriteLine("\nCarro " + (i + 1) + ":\n");
                aux.mostrar();
                preço = aux.preço();
                Console.WriteLine("RS" + preço);
            }
        }
Ejemplo n.º 5
0
        public Tempo Sub(Tempo t1, Tempo t2)
        {
            int h, m, s;

            h = t1.hora - t2.hora;
            m = t1.min - t2.min;
            s = t1.seg - t2.seg;
            if (s < 0)
            {
                s = s * (-1);
            }
            if (m < 0)
            {
                m = m * (-1);
            }
            if (h < 0)
            {
                h = h * (-1);
            }

            Tempo t3 = new Tempo(h, m, s);

            return(t3);
        }
Ejemplo n.º 6
0
 public float modulo(Tempo t1)
 {
     return(t1.hora + (t1.seg / 3600) + (t1.min / 60));
 }