using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MeesJaArmuke { class Tutvumispaik { Random random = new Random(); List armukesed = new List(); public void Registreeri(Armuke a) { armukesed.Add(a); } public bool OtsiJuhuslikArmuke(Vanamees kellele) { if (armukesed.Count == 0) { return false; } if (random.NextDouble() < 0.7) { return false; } Armuke a=armukesed[random.Next(armukesed.Count)]; Seo(kellele, a); return true; } void Seo(Vanamees v, Armuke a) { a.SeoVanamehega(v); v.LisaArmuke(a); } public override string ToString() { StringBuilder vastus = new StringBuilder("Armukesed: "); foreach (Armuke a in armukesed) { vastus.Append(a.ToString()+" "); } return vastus.ToString(); } } }