added box class

This commit is contained in:
szabomarton 2025-03-14 11:19:14 +01:00
parent 1ebc6c67b6
commit 63a0218e9d
13 changed files with 55 additions and 9 deletions

View File

@ -7,7 +7,7 @@
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|c:\\users\\szabomarton\\desktop\\verseny\\fordulo_3\\program\\doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
@ -28,7 +28,7 @@
"RelativeDocumentMoniker": "Doboz.cs",
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs",
"RelativeToolTip": "Doboz.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAABgAAAAJAAAAAAAAAA==",
"ViewState": "AgIAABMAAAAAAAAAAAAUwCIAAAA5AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-14T09:40:24.572Z",
"EditorCaption": ""
@ -41,7 +41,7 @@
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs",
"RelativeToolTip": "Program.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAiwBIAAAANAAAAAAAAAA==",
"ViewState": "AgIAAA8AAAAAAAAAAAAqwCQAAAAhAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-12T12:54:16.847Z",
"EditorCaption": ""

View File

@ -7,7 +7,7 @@
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|c:\\users\\szabomarton\\desktop\\verseny\\fordulo_3\\program\\doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
@ -28,7 +28,7 @@
"RelativeDocumentMoniker": "Doboz.cs",
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs",
"RelativeToolTip": "Doboz.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAABgAAAAJAAAAAAAAAA==",
"ViewState": "AgIAABMAAAAAAAAAAAAUwCIAAAA5AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-14T09:40:24.572Z",
"EditorCaption": ""
@ -41,7 +41,7 @@
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs",
"RelativeToolTip": "Program.cs",
"ViewState": "AgIAAAMAAAAAAAAAAAAiwBUAAAAJAAAAAAAAAA==",
"ViewState": "AgIAAA8AAAAAAAAAAAAqwBgAAAAeAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-12T12:54:16.847Z",
"EditorCaption": ""

View File

@ -8,13 +8,13 @@ namespace Program
{
internal class Doboz
{
public string Type { get; set; }
public char Type { get; set; }
public Doboz Children = null;
public Doboz Parent = null;
public Doboz(string Type) {
public Doboz(char Type) {
this.Type = Type;
}
@ -23,5 +23,20 @@ namespace Program
doboz.Parent = this;
this.Children = doboz;
}
public void PrintBoxContent(int indent = 0)
{
string indentStr = "";
for (int i = 0; i < indent; i++)
{
indentStr += "->";
}
Console.WriteLine($"{indentStr}{this.Type}");
if (this.Children != null)
{
this.Children.PrintBoxContent(indent + 1);
}
}
}
}

View File

@ -17,7 +17,38 @@ namespace Program
foreach (var item in AllBoxes)
{
Console.WriteLine(item);
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();
}
}