Created
May 18, 2012 01:40
-
-
Save nelsonlaquet/2722635 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Collections; | |
namespace ConsoleApplication1 | |
{ | |
interface IItem | |
{ | |
} | |
class Key : IItem | |
{ | |
} | |
class Inventory : IEnumerable | |
{ | |
private List<IItem> _items; | |
public Inventory() | |
{ | |
_items = new List<IItem>(); | |
} | |
public void Add(IItem item) | |
{ | |
if (_items.Contains(item)) | |
throw new InvalidOperationException(); | |
_items.Add(item); | |
Console.WriteLine("ADDING ITEM!"); | |
} | |
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var key = new Key(); | |
var inventory = new Inventory | |
{ | |
key, | |
key, | |
new Key(), | |
new Key(), | |
new Key(), | |
new Key() | |
}; | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment