Các class và source code tương ứng :
Item.cs
Visual C# Code:
namespace ConsoleApplication2 { { { } { } { _Name = name; } } }
File.cs
Visual C# Code:
namespace ConsoleApplication2 { { { _Content = content; } { } { } { } { } } }
Folder.cs
Visual C# Code:
Program.cs
Visual C# Code:
namespace ConsoleApplication2 { class Program { { resources.AddChild(xpTheme); resources.AddChild(icon); driver.AddChild(intel); driver.AddChild(asus); win32.AddChild(resources); win32.AddChild(driver); diskc.AddChild(win32); Console.WriteLine(diskc.ToString()); Console.WriteLine("Total size = " + diskc.CalcSize()); } } }
P/s: nhc cũng mới học thôi, các cao thủ về Design Pattern thấy có gì ko hợp lý trong cách cài đặt (cũng như ý tưởng) cứ lên tiếng nhé. Chân thành cám ơn mọi đóng góp![]()
Regards
Mới xem kĩ lại, thấy cái _Items để ở class Item hơi thừa, nhưng ko ảnh hưởng lắm đến hòa bình thế giới