using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Program { class Program { public static List Boxes = new List(); static void Main(string[] args) { string path = "../../../forrasok/dobozok.txt"; var AllBoxes = File.ReadAllText(path).ToCharArray(); foreach (var item in AllBoxes) { Doboz doboz = new Doboz(item); foreach (var box in Boxes) { if (doboz.Type == 'A') { break; } if (box.Type == 'A' && box.Children == null) { if (doboz.Type == 'B' || doboz.Type == 'C') { box.AddChildren(doboz); break; } } if (box.Type == 'B' && box.Children == null) { if (doboz.Type == 'C') { box.AddChildren(doboz); break; } } } Boxes.Add(doboz); } foreach (var item in Boxes) { item.PrintBoxContent(); } } } }