Safe Class
Sigiloso
public class Safe { private readonly List items = new List(); private readonly int capacity; public Safe(int capacity) { this.capacity = capacity; } public int Capacity { get { return this.capacity; } } public IEnumerable Items { get { return this.items.ToArray(); } } public void AddItem(string item) { Console.WriteLine(this.items.Count+1); if (this.items.Count > this.capacity) throw new InvalidOperationException(); this.items.Add(item); } public override string ToString() { return "Safe: " + this.items.Count + "/" + this.capacity; //return String.Format("Safe: (0)/(1)", this.items.Count, this.capacity); } }