Exemplo n.º 1
0
        public Alquiler buscarAlquiler(Vehiculo veh)
        {
            Alquiler alq = null;

            if (veh != null)
            {
                int i = 0;
                while (i < alquileres.Count && alq == null)
                {
                    if (alquileres[i].Vehiculo.Equals(veh) && !alquileres[i].disponibilidadVehiculo())
                    {
                        alq = alquileres[i];
                    }

                    i++;
                }
            }

            return(alq);
        }
Exemplo n.º 2
0
        public string registrarAlquiler(Cliente cliente, Vehiculo vehiculo, int horaInicio, int horaFin, DateTime fechaInicio, DateTime fechaFin)
        {
            string devolucion = "";

            if (cliente != null)
            {
                if (vehiculo != null)
                {
                    if (verificarHoras(horaInicio, horaFin))
                    {
                        if (verificarFechas(fechaInicio, fechaFin))
                        {
                            Alquiler alq = new Alquiler(cliente, vehiculo, horaInicio, horaFin, fechaInicio, fechaFin);
                            alquileres.Add(alq);
                            string costo = alq.calcularCosto().ToString();
                            devolucion = "CORRECTO: Alquiler agregado con exito<br>Costo: $" + costo;
                        }
                        else
                        {
                            devolucion = "ERROR: Fechas invalidas";
                        }
                    }
                    else
                    {
                        devolucion = "ERROR: Horas invalidas";
                    }
                }
                else
                {
                    devolucion = "ERROR: Vehiculo invalido";
                }
            }
            else
            {
                devolucion = "ERROR: Cliente invalido";
            }

            return(devolucion);
        }
Exemplo n.º 3
0
        public string devolverVehiculo(Vehiculo veh)
        {
            Alquiler alq        = buscarAlquiler(veh);
            string   devolucion = "";

            if (alq != null)
            {
                if (alq.devolverVehiculo())
                {
                    devolucion = "CORRECTO: Vehiculo devuelto con exito";
                }
                else
                {
                    devolucion = "ERROR: Fallo al devolver el vehiculo";
                }
            }
            else
            {
                devolucion = "ERROR: Alquiler inexistente";
            }

            return(devolucion);
        }