public void Park(Vehical vehical) { if (IsEmpty) { parkedVehical = vehical; } }
public Vehical Leave(Ticket ticket) { if (ticket != null && ticketRecorder.ContainsKey(ticket)) { Spot spot = ticketRecorder[ticket]; Vehical v = spot.Leave(); return(v); } return(null); }
public Vehical Leave() { if (!IsEmpty) { var vehical = parkedVehical; parkedVehical = null; return(vehical); } return(null); }
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); }
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); }