made some progress

This commit is contained in:
Digi
2025-03-13 21:22:31 +01:00
parent f92b3d93ef
commit 125039f7af
23 changed files with 1825 additions and 138 deletions

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
namespace Program
{
public class Virus
{
public int Name { get; set; }
public Virus Parent { get; set; }
public List<Virus> Infected { get; private set; }
public int InfectionTurn { get; set; }
public Virus(int name, int infectionTurn = 0)
{
Name = name;
Infected = new List<Virus>();
InfectionTurn = infectionTurn;
}
public Virus(int name, Virus parent, int infectionTurn = 0) : this(name, infectionTurn)
{
Parent = parent;
}
public void Infect(Virus virus)
{
virus.Parent = this;
Infected.Add(virus);
}
public void PrintInfectionTree(string indent = "")
{
Console.WriteLine($"{indent}Virus {Name}");
foreach (var infected in Infected)
{
infected.PrintInfectionTree(indent + " ");
}
}
public void PrintInfectionTreeWithDepth(int maxDepth, int currentDepth = 0, string indent = "")
{
if (currentDepth > maxDepth) return;
Console.WriteLine($"{indent}Virus {Name}");
foreach (var infected in Infected)
{
infected.PrintInfectionTreeWithDepth(maxDepth, currentDepth + 1, indent + " ");
}
}
}
}