コード例 #1
0
 public void Add(SummonInformation summonInformation)
 {
     if (!_visitationPlan.Contains(summonInformation))
     {
         _visitationPlan.Add(summonInformation);
     }
 }
コード例 #2
0
        public bool CanAddToExecutionPlan(SummonInformation summon)
        {
            if (summon.IsInsideCall())
            {
                return(IsTriggeringSummonInExecutionPlan(summon.TriggeringSummon));
            }

            return(true);
        }
コード例 #3
0
        public override bool Equals(object obj)
        {
            SummonInformation summonInfo = (SummonInformation)obj;

            if (summonInfo == null)
            {
                return(false);
            }
            return(this.SummonFloor == summonInfo.SummonFloor &&
                   this.Direction == summonInfo.Direction);
        }
コード例 #4
0
 public SummonInformation(int currentFloor, TravelDirection direction = TravelDirection.None, SummonInformation triggeringSummon = null)
 {
     SummonFloor = currentFloor;
     Direction   = direction;
     if (direction == TravelDirection.None)
     {
         TriggeringSummon = triggeringSummon;
     }
     else
     {
         TriggeringSummon = null;
     }
 }
コード例 #5
0
 private bool IsTriggeringSummonInExecutionPlan(SummonInformation triggeringSummon)
 {
     return(_visitationPlan.Contains(triggeringSummon));
 }
コード例 #6
0
 private bool IsFirstRequestForCurrentFloor(SummonInformation summonInformation)
 {
     return(CurrentFloor == summonInformation.SummonFloor);
 }
コード例 #7
0
 private TravelDirection DeduceTravelDirection(SummonInformation summon)
 {
     return((CurrentFloor < summon.SummonFloor)
         ? TravelDirection.Up
         : TravelDirection.Down);
 }
コード例 #8
0
 private TravelDirection GetInitialDirectionOfTravel(SummonInformation firstSummon)
 {
     return(firstSummon.SummonFloor == CurrentFloor
         ? firstSummon.Direction
         : DeduceTravelDirection(firstSummon));
 }
コード例 #9
0
 private bool IsSummonRequestInBoundariesAndMatchingDirection(SummonInformation summon, TravelDirection direction, Tuple <int, int> boundaries)
 {
     return((summon.Direction == direction || summon.Direction == TravelDirection.None) &&
            summon.SummonFloor.Between(boundaries.Item1, boundaries.Item2));
 }
コード例 #10
0
 private bool NeedToRunSameSegmentInOppositeDirection(SummonInformation firstSummon, TravelDirection direction)
 {
     return(firstSummon.Direction != direction);
 }
コード例 #11
0
 public void SummonCall(SummonInformation summonInfo)
 {
     _door.RequestOpening();
 }