| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Buhnenrennen
- {
- class Groyne
- {
- public double YCoord { get; private set; }
- public char Type { get; private set; }
-
- public Groyne( double yCoord, char type )
- {
- this.YCoord = yCoord;
- this.Type = type;
- }
-
- /// <summary>
- /// returns if given dog fits through the groyne
- /// </summary>
- /// <param name="dog">the dog, that wants to fit through</param>
- public bool CanPass( Dog dog ) => dog.FitsThrough.Contains( Type );
-
- /// <summary>
- /// returns the distance between called and given groyne
- /// </summary>
- /// <param name="groyne">groyne to calculate the distance to</param>
- public double DistanceTo( Groyne groyne ) =>
- // distance: distance² = A² + B²
- // A: 70
- // B: difference of Y-Coordinates
- Math.Sqrt( Math.Pow( 70, 2 ) + Math.Pow( YCoord - groyne.YCoord, 2 ) );
-
- /// <summary>
- /// returns the time the given {dog} needs to get to given {groyne} starting at current groyne
- /// </summary>
- /// <param name="groyne">groyne the dog is running to</param>
- /// <param name="dog">the dog, thats running to the groyne</param>
- public double RequiredTimeTo( Groyne groyne, Dog dog ) => DistanceTo( groyne ) / dog.MeterPerSecond;
-
- public override string ToString() => Type + "( " + YCoord + " )";
- }
- }
|