예제 #1
0
        void ride(BO.Bus bus, double km)
        {
            if (bus.KilometersAfterFueling + km >= BO.Bus.MAX_KILOMETER_AFTER_REFUELING)
            {
                throw new BO.BadBusException(bus.LicenseNum, "This bus need refueling to make this trip");
            }

            if (DateTime.Today.AddYears(-1) > bus.LastTreatment ||
                bus.KilometersAfterTreatment + km >= BO.Bus.KILOMETER_BEFORE_TREATMENT)
            {
                throw new BO.BadBusException(bus.LicenseNum, "This bus need treatment to make this trip");
            }

            bus.TotalTrip += km;
            bus.KilometersAfterFueling   += km;
            bus.KilometersAfterTreatment += km;
            bus.FuelRemain -= (BO.Bus.FULL_CONTAINER / BO.Bus.MAX_KILOMETER_AFTER_REFUELING) * km;
        }
예제 #2
0
        /// <summary>
        /// make a treatment, refueling, ride to the bus
        /// </summary>
        /// <param name="bus">the bus</param>
        /// <param name="service">kind of service</param>
        /// <param name="tripKm">if the sevice is ride that will be the kilometers</param>
        public void BusServices(BO.Bus bus, string service, double tripKm = 0)
        {
            switch (service)
            {
            case "Treatment":
                treatment(bus);
                break;

            case "Refueling":
                refueling(bus);
                break;

            case "Ride":
                ride(bus, tripKm);
                break;
            }
            UpdateBus(bus);
        }
예제 #3
0
        /// <summary>
        /// Add a new bus to my Data Source
        /// </summary>
        /// <param name="bus"></param>
        public void AddBus(BO.Bus bus)
        {
            if (bus.FromDate.Year >= 2018 && bus.LicenseNum.ToString().Length != 8)
            {
                throw new BO.BadBusException(bus.LicenseNum, "not valid lisense number for bus from year 2018");
            }

            if (bus.FromDate.Year <= 2017 && bus.LicenseNum.ToString().Length != 7)
            {
                throw new BO.BadBusException(bus.LicenseNum, "not valid lisense number for bus from year under 2017");
            }

            var busDo = bus.CopyPropertiesToNew(typeof(DO.Bus)) as DO.Bus;

            try
            {
                dl.AddBus(busDo);
            }
            catch (DO.BadBusException ex)
            {
                throw new BO.BadBusException(bus.LicenseNum, ex.Message);
            }
        }
예제 #4
0
 void refueling(BO.Bus bus)
 {
     bus.Status = BO.BusStatus.REFUELING;
     bus.KilometersAfterFueling = 0;
     bus.FuelRemain             = BO.Bus.FULL_CONTAINER;
 }
예제 #5
0
 void treatment(BO.Bus bus)
 {
     bus.Status = BO.BusStatus.TREATMENT;
     bus.KilometersAfterTreatment = 0;
     bus.LastTreatment            = DateTime.Now;
 }