class Boat { // Attributes private string _name; // Constructors public Boat(string name) { _name = name; } // Properties public string Name { get { return _name; } set { _name = value; } } // Methods } class Harbour { // Start of class // Attributes private List _boats; // Constructors public Harbour() { _boats = new List(); } // Properties // Methods public void Dock(Boat boat) { _boats.Add(boat); // Store Boat object on list } public Boat FindByName(string name) { foreach (Boat boat in _boats) { if (boat.Name == name) { return boat; // Found boat } } return null; // No Boat object exists for this name } } // End of Class static void Main(string[] args) { Boat boat; Harbour harbour; boat = new Boat("Fred"); harbour = new Harbour(); harbour.Dock(boat); harbour.Dock(new Boat("John")); boat = harbour.FindByName("Fred"); if (boat != null) { Console.WriteLine("Found the boat {0}", boat.Name); } boat = harbour.FindByName("RubbishName"); if (boat == null) { Console.WriteLine("Boat should be null"); } }