1
0

Program.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace DecoratorPattern
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Console.WriteLine("装饰模式:");
  13. Console.WriteLine("-------------------------------------------------");
  14. Console.WriteLine("先看毛坯房:");
  15. //未经装修的毛坯房
  16. var withoutDecoratorHouse = new WithoutDecoratorHouse()
  17. {
  18. Area = 80.0,
  19. Specification="三室一厅一卫",
  20. Price = 8000
  21. };
  22. withoutDecoratorHouse.Show();
  23. Console.WriteLine("-------------------------------------------------");
  24. Console.WriteLine("再看样板房:");
  25. //对毛坯房进行装修
  26. var decoratorHouse = new ModelHouse(withoutDecoratorHouse);
  27. decoratorHouse.Show();
  28. Console.WriteLine("-------------------------------------------------");
  29. Console.ReadLine();
  30. }
  31. }
  32. }