Ejemplo n.º 1
0
 private void InitializeParkingSlots()
 {
     for (int i = 0; i < slots.Length; i++)
     {
         slots[i] = new ParkingSlot()
         {
             SlotNumber = i
         };
     }
 }
Ejemplo n.º 2
0
        public void Park(Vechile vechile)
        {
            bool carParked = false;

            foreach (var level in _Levels)
            {
                if (level.HasFreeSlot())
                {
                    ParkingSlot slot = level.GetNearestFreeSlot();
                    slot.OccupySlot(vechile);
                    Console.WriteLine(string.Format("{0} {1} parked at level {2} slot {3}", vechile.Model, vechile.Type.ToString(), level.LevelNumber, slot.SlotNumber));
                    Console.WriteLine();
                    carParked      = true;
                    vechile.Status = ParkingStatus.Parked;
                    vechile.CountDownForExit();
                    break;
                }
            }
            if (!carParked)
            {
                Console.WriteLine(string.Format("{0} {1} is rejected because there is no free space at the garage", vechile.Model, vechile.Type.ToString()));
                Console.WriteLine();
            }
        }
Ejemplo n.º 3
0
        public void Exit(Vechile vechile)
        {
            ParkingSlot slot = slots.Single(s => s.IsOccupiedWith(vechile));

            slot.FreeSlot();
        }