コード例 #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);
        }