예제 #1
0
        public double ParkingCost(string parkingSpace, string parkingLevel)
        {
            GeneralParking       generalParking       = new GeneralParking();
            ValetParking         valetParking         = new ValetParking();
            FrequentFlyerParking frequentFlyerParking = new FrequentFlyerParking();
            var    parkingDetails = ParkingSpots.Find(x => x.ParkingSpotNumber == parkingSpace && x.ParkingStructureLevel == parkingLevel);
            var    minutesParked  = (DateTime.Now - parkingDetails.StartTime).TotalMinutes;
            double totalCost      = 0;

            switch (parkingDetails.GetParkingType)
            {
            case ParkingType.General:
                totalCost = (minutesParked / 60) * generalParking.ParkingPrice;
                break;

            case ParkingType.Valet:
                totalCost = (minutesParked / 60) * valetParking.ParkingPrice;
                break;

            case ParkingType.FrequentFlyer:
                totalCost = (minutesParked / 60) * frequentFlyerParking.ParkingPrice;
                break;

            default:
                throw new Exception("Time error");
            }

            return(totalCost);
        }
예제 #2
0
        public double ParkingCost(ParkingType parkingType, ParkingSpot parkingSpot)
        {
            GeneralParking       generalParking       = new GeneralParking();
            ValetParking         valetParking         = new ValetParking();
            FrequentFlyerParking frequentFlyerParking = new FrequentFlyerParking();
            var    hoursParked = ((DateTime.Now - parkingSpot.StartTime).Minutes) / 60;
            double totalPrice  = 0;

            switch (parkingType)
            {
            case ParkingType.General:
                totalPrice = (hoursParked) * generalParking.ParkingPrice;
                break;

            case ParkingType.Valet:
                totalPrice = (hoursParked) * valetParking.ParkingPrice;
                break;

            case ParkingType.FrequentFlyer:
                totalPrice = (hoursParked) * frequentFlyerParking.ParkingPrice;
                break;

            default:
                throw new Exception("Time error");
            }
            ;

            return(totalPrice);
        }