Esempio n. 1
0
 public void AddApple(Apple apple, int position)
 {
     if (_apples[position] != null)
     {
         throw new ArgumentException("Compartment already occupied", nameof(position));
     }
     if (apple == null)
     {
         throw new ArgumentNullException(nameof(apple));
     }
     if (position < 0 || position > _apples.Length - 1)
     {
         throw new IndexOutOfRangeException("Cannot add apple outside compartments");
     }
     apple.MoveToBox(this, position);
 }
Esempio n. 2
0
 public int GetApplePosition(Apple apple)
 {
     return(Array.IndexOf(_apples, apple));
 }