コード例 #1
0
        public bool TryAdd(Boat boat, BerthingAlgorithm algorithm)
        {
            if (Boats.Contains(boat))
            {
                throw new ArgumentException("A boat with the same id is already berthed.", nameof(boat));
            }

            int index = algorithm(boat, berthSpots);

            if (index < 0)
            {
                return(false);
            }
            AddBoat(boat, index);

            return(true);
        }
コード例 #2
0
 public void SetBerthingAlgorithm(BerthingAlgorithm algorithm, string algorithmName)
 {
     berthingAlgorithm  = algorithm;
     this.algorithmName = algorithmName;
 }