예제 #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);
        }
        public override bool Equals(object obj)
        {
            SummonInformation summonInfo = (SummonInformation)obj;

            if (summonInfo == null)
            {
                return(false);
            }
            return(this.SummonFloor == summonInfo.SummonFloor &&
                   this.Direction == summonInfo.Direction);
        }
 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();
 }