/// <summary>创建一张票 /// </summary> /// <param name="seat"></param> /// <param name="segment"></param> /// <returns></returns> private Ticket CreateTicket(Seat seat, Segment segment) { var startStation = _stations.Single(x => x.No == segment.StartNo); var endStation = _stations.Single(x => x.No == segment.EndNo); return new Ticket(seat.No, startStation, endStation); }
/// <summary>将给定座位出售给给定的订票区间 /// </summary> /// <param name="seat"></param> /// <param name="segment"></param> /// <param name="atomSegments"></param> private void SellSeat(Seat seat, Segment segment, IEnumerable<Segment> atomSegments) { foreach (var atomSegment in atomSegments) { _atomSegments[atomSegment] = _atomSegments[atomSegment] - 1; } seat.AddSoldSegment(segment); if (!_soldSeats.ContainsKey(seat.No)) { _soldSeats.Add(seat.No, seat); _cleanSeats.Remove(seat.No); } }
/// <summary>根据站点数和座位数初始化车次 /// </summary> /// <param name="stationCount"></param> /// <param name="seatCount"></param> /// <returns></returns> public TrainShift Inatialize(int stationCount, int seatCount) { _stations.Clear(); _soldSeats.Clear(); _cleanSeats.Clear(); _atomSegments.Clear(); //初始化站点列表,初始化原子区间的可用票数 for (var i = 1; i <= stationCount; i++) { _stations.Add(new Station("station" + i, i, DateTime.Now)); if (i >= 2) { _atomSegments.Add(new Segment(i - 1, i), seatCount); } } //初始化座位 for (var i = 1; i <= seatCount; i++) { var seat = new Seat(i); _cleanSeats.Add(seat.No, seat); } return this; }
public void RemoveSeat(Seat Seat) { Seats.Remove(Seat); }
public void AddSeat(Seat Seat) { Seats.Add(Seat); }
public TrainOrderItem(Seat Seat, UserContract UserContract, decimal Price) : base() { this.Seat = Seat; this.UserContract = UserContract; this.Price = Price; }
public DestinationSeat(Seat Seat, IList <TrainStationWay> TrainStationWays) : base() { this.Seat = Seat; this.TrainStationWays = TrainStationWays; }