Neumann_Janos_Verseny/fordulo_3/Program/Program.cs
2025-03-14 11:19:14 +01:00

57 lines
1.5 KiB
C#

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<Doboz> Boxes = new List<Doboz>();
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();
}
}
}
}