コード例 #1
0
ファイル: Plane.cs プロジェクト: shimanskIA/QA-Automation
        public double GetFlyTime(Coordinate coordinate) // every 10 kilometers the speed increases in 10 km/h
        {
            double distance    = ActualCoordinate.GetDistance(coordinate);
            double actualSpeed = TakeoffSpeed;

            if (distance <= _maximalDistance)
            {
                int    amountOfSpeedChanges = (int)(distance / _increaseInterval);
                double lastDistance         = distance - amountOfSpeedChanges * _increaseInterval;
                double time = 0;
                for (int i = 0; i < amountOfSpeedChanges; i++)
                {
                    time += _increaseInterval / actualSpeed;
                    if (MaximalSpeed - _speedInscrease - actualSpeed < 0)
                    {
                        actualSpeed = MaximalSpeed;
                    }
                    else
                    {
                        actualSpeed += _speedInscrease;
                    }
                }
                return(time += (lastDistance / actualSpeed));
            }
            else
            {
                throw new ArgumentOutOfRangeException("planes are not able to fly more than" + _maximalDistance + "km");
            }
        }
コード例 #2
0
 public void FlyTo(Coordinate coordinate) // changes the actual coordinate if distance is less than maximal distance of the flight
 {
     if (ActualCoordinate.GetDistance(coordinate) <= MaximalDistance)
     {
         ActualCoordinate.X = coordinate.X;
         ActualCoordinate.Y = coordinate.Y;
         ActualCoordinate.Z = coordinate.Z;
     }
     else
     {
         throw new ArgumentOutOfRangeException("drones are not able to fly more than " + MaximalDistance + " km");
     }
 }
コード例 #3
0
ファイル: Bird.cs プロジェクト: shimanskIA/QA-Automation
        public double GetFlyTime(Coordinate coordinate) // speed chosen randomly from 0 to 20 km/h
        {
            double distance = ActualCoordinate.GetDistance(coordinate);

            if (distance <= _maximalDistance)
            {
                return(ActualCoordinate.GetDistance(coordinate) / Speed);
            }
            else
            {
                throw new ArgumentOutOfRangeException("birds are not able to fly more than" + _maximalDistance + "km");
            }
        }
コード例 #4
0
ファイル: Bird.cs プロジェクト: shimanskIA/QA-Automation
 public void FlyTo(Coordinate coordinate) // changes the actual coordinate if distance is less than 1500 km
 {
     if (ActualCoordinate.GetDistance(coordinate) <= _maximalDistance)
     {
         ActualCoordinate.X = coordinate.X;
         ActualCoordinate.Y = coordinate.Y;
         ActualCoordinate.Z = coordinate.Z;
     }
     else
     {
         throw new ArgumentOutOfRangeException("birds are not able to fly more than" + _maximalDistance + "km");
     }
 }
コード例 #5
0
        public double GetFlyTime(Coordinate coordinate) // each 10 minutes of flight makes a 1 minute pause then moves again
        {
            double distance = ActualCoordinate.GetDistance(coordinate);

            if (distance <= MaximalDistance)
            {
                double baseTime      = distance / Speed;
                int    amountOfStops = (int)(baseTime / _tenMinutesInHours);
                return(baseTime + amountOfStops * _oneMinuteInHours);
            }
            else
            {
                throw new ArgumentOutOfRangeException("drones are not able to fly more than " + MaximalDistance + " km");
            }
        }
コード例 #6
0
ファイル: Plane.cs プロジェクト: shimanskIA/QA-Automation
 public void FlyTo(Coordinate coordinate) // changes the actual coordinate if distance is less than 25000 km
 {
     if (ActualCoordinate.GetDistance(coordinate) <= _maximalDistance)
     {
         ActualCoordinate.X = coordinate.X;
         ActualCoordinate.Y = coordinate.Y;
         ActualCoordinate.Z = coordinate.Z;
     }
     else
     {
         // some airport coordinates
         ActualCoordinate.X = 100;
         ActualCoordinate.Y = 100;
         ActualCoordinate.Z = 100;
     }
 }