예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="vehicle"></param>
        /// <param name="infraction"></param>
        /// <returns></returns>
        public virtual TrafficViolation CreateTrafficViolation(Driver driver, Vehicle vehicle, Infraction infraction)
        {
            TrafficViolation trafficViolation = new TrafficViolation();

            try
            {
                trafficViolation.SetDriver(driver);
                trafficViolation.SetVehicle(vehicle);
                trafficViolation.SetInfraction(infraction);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }

            return(trafficViolation);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="trafficViolations"></param>
        /// <returns></returns>
        public virtual List <TrafficViolation> CreateTrafficViolationList(List <string[]> trafficViolations)
        {
            List <TrafficViolation> listOfTrafficViolation = new List <TrafficViolation>();

            try
            {
                TrafficViolation trafficViolation = new TrafficViolation();
                foreach (var violation in trafficViolations)
                {
                    Infraction       infractions   = trafficViolation.CreateInfraction(SplitTheData(violation[0], ','));
                    Driver           drivers       = trafficViolation.CreateDriver(SplitTheData(violation[1], ','));
                    Vehicle          vehicles      = trafficViolation.CreateVehicle(SplitTheData(violation[2], ','));
                    TrafficViolation trafficCasess = CreateTrafficViolation(drivers, vehicles, infractions);
                    listOfTrafficViolation.Add(trafficCasess);
                }
            }
            catch (IndexOutOfRangeException ex)
            {
                throw new IndexOutOfRangeException(ex.Message.ToString());
            }

            return(listOfTrafficViolation);
        }