Ejemplo n.º 1
0
 public void Park(Vehical vehical)
 {
     if (IsEmpty)
     {
         parkedVehical = vehical;
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
        public Vehical Leave()
        {
            if (!IsEmpty)
            {
                var vehical = parkedVehical;
                parkedVehical = null;
                return(vehical);
            }

            return(null);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }