✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
public interface INode { int Size(); }
public sealed class FileLeaf : INode
{
private readonly int _bytes;
public FileLeaf(int bytes) => _bytes = bytes;
public int Size() => _bytes;
}
public sealed class FolderComposite : INode
{
private readonly List
_children = new();
public void Add(INode n) => _children.Add(n);
public int Size() => _children.Sum(c => c.Size());
}
Який патерн ілюструє цей код?