Exemplo n.º 1
0
 public ParkingLotTests()
 {
     clock = new TestClock();
     lot   = new ParkingLot(clock, 15, TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(0));
     lot   = new ParkingLot(clock, new FotexPriceStrategy());
     Gates.Reset();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Method to show options and parking lot properties
 /// </summary>
 /// <param name="parkingLot">the object ParkingLot</param>
 private static void ShowMessages(IParkingLot parkingLot)
 {
     Console.Write("\nBienvenidos a Parking System \n\n");
     Console.Write("\nCantidad de autos estacionados: " + parkingLot.CantidadEstacionados);
     Console.Write("\nCantidad de espacio disponible: " + parkingLot.EspaciosDisponibles);
     Console.Write("\n\nPor favor elija una opción: ");
     Console.Write("\n1. Ingresar Auto. \n2. Egresar Auto. \n3. Facturar. \n4. Cerrar programa.\n");
 }
Exemplo n.º 3
0
        private static void AllocateParkingSlot(VehicleBase vehicle, IParkingLot parkingLot)
        {
            IParkingSlot availableParkingSlot = parkingLot.FindParking(vehicle);

            if (availableParkingSlot != null)
            {
                parkingLot.AllocateParkingSlot(vehicle, availableParkingSlot);
            }
        }
        /// <summary>
        /// Setups the parking system for the first time
        /// </summary>
        /// <param name="rows">Number of rows in parking lot</param>
        /// <param name="columns">Number of columns in parking lot</param>
        /// <param name="reservedParkingRows">List of reserved parking rows</param>
        public void SetupSystem(int rows, int columns, IEnumerable <int> reservedParkingRows)
        {
            if (rows <= 0 || columns <= 0)
            {
                throw new InvalidOperationException("There should be at least one row and column in the parking lot");
            }

            _parkingLot = _parkingLotFactory.CreateParkingLot(rows, columns, reservedParkingRows);
        }
Exemplo n.º 5
0
        public static void HandleParkers(Queue <Parker> parkers)
        {
            PrintQueue(parkers);
            int parkerCount = parkers.Count;

            Console.CursorTop = 4;
            while (parkers.Count > 0)
            {
                var parker     = parkers.Dequeue();
                var parkerType = parker.IsContractor ? "Contractor" : "Employee";

                Console.WriteLine($"\nWould you like to park in the surface lot or parking garage?");
                Console.Write("Enter s or g:");
                bool validResponse = false;

                IParkingLot parkingLot = null;

                while (!validResponse)
                {
                    var enteredText = Console.ReadLine().Trim().ToLower();
                    if (!String.Equals(enteredText, "s", StringComparison.OrdinalIgnoreCase) &&
                        !String.Equals(enteredText, "g", StringComparison.OrdinalIgnoreCase))
                    {
                        var currentPosition = Console.CursorTop;
                        RefreshConsole(parkers);
                        Console.SetCursorPosition(0, 7);
                        Console.Write("Invalid input. Please enter s or g:");
                    }
                    else
                    {
                        validResponse = true;

                        if (String.Equals(enteredText, "g", StringComparison.OrdinalIgnoreCase))
                        {
                            parkingLot = new ParkingGarage(parker);
                        }
                        else
                        {
                            parkingLot = new SurfaceLot();
                        }
                    }
                }

                parkingLot?.Park();

                parkerCount--;

                Console.WriteLine("\nPress any key to continue...");
                Console.ReadKey();

                RefreshConsole(parkers);
                Console.CursorTop = 4;
            }
        }
Exemplo n.º 6
0
        private static IParkingLot BuildParkingLot()
        {
            IParkingLot parkingLot = null;

            Console.WriteLine("Initialize parking lot with parking levels");
            Console.WriteLine("Please enter number of levels");

            int numberOfParkingLevels = Convert.ToInt32(Console.ReadLine());

            parkingLot = FactoryParkingLot.Create(numberOfParkingLevels);

            return(parkingLot);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            IParkingLot parkingLot = BuildParkingLot();

            if (parkingLot != null)
            {
                //// Configure Parking Lot with Paking Slots
                //parkingLot.ConfigureParking();

                VehicleBase vehicle = FactoryVehicle.Create(VehicleType.Bus);

                AllocateParkingSlot(vehicle, parkingLot);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Enter the specified parkingLot.
        /// </summary>
        /// <param name="parkingLot">Parking lot.</param>
        public void Enter(IParkingLot parkingLot)
        {
            if (parkingLot == null)
            {
                throw new ArgumentException("Car must enter a valid parking lot.");
            }

            if (this.ParkingLot != null)
            {
                throw new Exception("This car is already in a parking lot.");
            }

            this.ParkingLot = parkingLot;
            // Initialize parking slip with an enter time
            this.ParkingSlip = new ParkingSlip(DateTime.UtcNow);
        }
Exemplo n.º 9
0
 public ParkingLotTests()
 {
     clock = new TestClock();
     lot   = new ParkingLot(clock, new FotexPriceStrategy());
     Gates.Reset();
 }
Exemplo n.º 10
0
 public ParkingLotCLI(IParkingLot parkingLot)
 {
     this.parkingLot = parkingLot;
 }
Exemplo n.º 11
0
 private static void DeAllocateParking(VehicleBase vehicle, IParkingLot parkingLot)
 {
     parkingLot.DeallocateParkingSlot(vehicle);
 }
Exemplo n.º 12
0
 public ParkingLotService(IParkingLot parkingLot)
 {
     _parkingLot = parkingLot;
 }
Exemplo n.º 13
0
 public ParkingLotTests()
 {
     clock = new TestClock();
     lot   = new ParkingLot(clock);
     Gates.Reset();
 }