コード例 #1
0
 /// <summary>
 /// Adds an object to the garden.
 /// </summary>
 /// <param name="newContent">The object to add, which must inherit from <see cref="GardenContent" />.</param>
 public void Add(GardenContent newContent)
 {
     // Check is inside garden
     if (newContent.XPos < 0 || newContent.XPos + newContent.Width > width ||
         newContent.YPos < 0 || newContent.YPos + newContent.Depth > depth)
     {
         throw new ArgumentException("That object doesn't fit in the garden!");
     }
     contents.Add(newContent);
 }
コード例 #2
0
 /// <summary>
 /// Determines whether an object is in the garden.
 /// </summary>
 /// <param name="content">The object to look for, which must inherit from <see cref="GardenContent" />.</param>
 /// <returns>A <see langword="bool" /> value, stating whether the object is in the garden.</returns>
 public bool Contains(GardenContent content)
 {
     return(contents.Contains(content));
 }
コード例 #3
0
 /// <summary>
 /// Removes an object from the garden.
 /// </summary>
 /// <param name="oldContent">The object to add, which must inherit from <see cref="GardenContent" />.</param>
 public void Remove(GardenContent oldContent)
 {
     contents.Remove(oldContent);
 }