Пример #1
0
 public void Park(Vehical vehical)
 {
     if (IsEmpty)
     {
         parkedVehical = vehical;
     }
 }
Пример #2
0
 public Vehical Leave(Ticket ticket)
 {
     if (ticket != null && ticketRecorder.ContainsKey(ticket))
     {
         Spot    spot = ticketRecorder[ticket];
         Vehical v    = spot.Leave();
         return(v);
     }
     return(null);
 }
Пример #3
0
        public Vehical Leave()
        {
            if (!IsEmpty)
            {
                var vehical = parkedVehical;
                parkedVehical = null;
                return(vehical);
            }

            return(null);
        }
Пример #4
0
        public Ticket Park(Vehical vehical)
        {
            Spot spot = FindSpot(vehical);

            if (spot != null)
            {
                Ticket ticket = new Ticket();
                ticket.Id       = spot.GetHashCode();
                ticket.parkTime = DateTime.Now;
                ticketRecorder.Add(ticket, spot);
                return(ticket);
            }

            return(null);
        }
Пример #5
0
        private Spot FindSpot(Vehical vehical)
        {
            if (vehical == null)
            {
                return(null);
            }

            if (vehical.vehicalSize == VehicalSize.Small)
            {
                foreach (var spot in small)
                {
                    if (spot.IsEmpty)
                    {
                        return(spot);
                    }
                }
            }
            else if (vehical.vehicalSize == VehicalSize.Medium)
            {
                foreach (var spot in medium)
                {
                    if (spot.IsEmpty)
                    {
                        return(spot);
                    }
                }
            }
            else
            {
                foreach (var spot in large)
                {
                    if (spot.IsEmpty)
                    {
                        return(spot);
                    }
                }
            }

            return(null);
        }