/// Constructor To Create RideRepository instance.
 /// </summary>
 /// <summary>
 public InvoiceGenerator(RideType rideType)
 {
     this.rideType       = rideType;
     this.rideRepository = new RideRepository();
     try
     {
         //If Ride type is Premium Then Rates Set For Premium else For Normal.
         if (rideType.Equals(RideType.PREMIUM))
         {
             this.MINIMUM_COST_PER_KM = 15;
             this.COST_PER_TIME       = 2;
             this.MINIMUM_FARE        = 20;
         }
         else if (rideType.Equals(RideType.NORMAL))
         {
             this.MINIMUM_COST_PER_KM = 10;
             this.COST_PER_TIME       = 1;
             this.MINIMUM_FARE        = 5;
         }
     }
     catch (CabInvoiceException)
     {
         throw new CabInvoiceException(CabInvoiceException.ExceptionType.INVALID_RIDE_TYPE, "Invalid Ride Type");
     }
 }
Exemplo n.º 2
0
 //Constructor to create Repositoru instance
 public InvoiceGenerator(RideType rideType)
 {
     this.rideType       = rideType;
     this.rideRepository = new RideRepository();
     try
     {
         //If Ride type is premium then rates set for premium else for normal
         if (rideType.Equals(RideType.Premium))
         {
             this.Min_Cost_Per_km = 15;
             this.Cost_Per_km     = 2;
             this.Min_Fare        = 20;
         }
         else if (rideType.Equals(RideType.Normal))
         {
             this.Min_Cost_Per_km = 10;
             this.Cost_Per_km     = 1;
             this.Min_Fare        = 5;
         }
         else
         {
             throw new CabInvoiceException(CabInvoiceException.ExceptionType.Invalid_Ride_Type, "Invalid Ride Type");
         }
     }
     catch (CabInvoiceException)
     {
         throw new CabInvoiceException(CabInvoiceException.ExceptionType.Invalid_Ride_Type, "Invalid Ride Type");
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Method to validate first name
        /// </summary>
        /// <param name="distance">total distance</param>
        /// <param name="time">total time</param>
        /// <param name="type">define type</param>
        /// <returns>total fare</returns>
        public double CalculateFare(double distance, int time, string type)
        {
            RideType rideType  = new RideType(type);
            double   totalFare = (distance * rideType.MINIMUMCOSTPERKILOMETER) + (time * rideType.COSTPERTIME);

            if (totalFare < rideType.MINIMUMFARE)
            {
                return(rideType.MINIMUMFARE);
            }

            return(totalFare);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InvoiceGenerator"/> class.
 /// </summary>
 /// <param name="rideType">Type of the ride.</param>
 public InvoiceGenerator(RideType rideType)
 {
     rideRepository = new RideRepository();
     if (rideType == RideType.NORMAL)
     {
         MINIMUM_COST_PER_KM = RideRate.NORMAL_MINIMUM_COST_PER_KM;
         COST_PER_TIME       = COST_PER_TIME = RideRate.NORMAL_COST_PER_TIME;
         MINIMUM_FARE        = MINIMUM_FARE = RideRate.NORMAL_MINIMUM_FARE;
     }
     else
     {
         MINIMUM_COST_PER_KM = RideRate.PREMIUM_MINIMUM_COST_PER_KM;
         COST_PER_TIME       = COST_PER_TIME = RideRate.PREMIUM_COST_PER_TIME;
         MINIMUM_FARE        = MINIMUM_FARE = RideRate.PREMIUM_MINIMUM_FARE;
     }
 }
Exemplo n.º 5
0
 public Invoice_Generator(RideType rideType)
 {
     this.rideType = rideType;
     if (rideType.Equals(RideType.NORMAL))
     {
         this.COST_PER_KM  = 10;
         this.COST_PER_MIN = 1;
         this.MIN_FARE     = 5;
     }
     else if (rideType.Equals(RideType.PREMIUM))
     {
         this.COST_PER_KM  = 15;
         this.COST_PER_MIN = 2;
         this.MIN_FARE     = 20;
     }
     else
     {
         throw new Cab_Invoice_Exception(Cab_Invoice_Exception.ExceptionType.INVALID_RIDE_TYPE, "Ride type is Invalid");
     }
 }