Example #1
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("欢迎来到.net高级班vip课程,今天是设计模式的学习");
                {
                    AbstractStudent student = new StudentVip()
                    {
                        Id   = 381,
                        Name = "候鸟"
                    };
                    //RegUser
                    //付费  要预习
                    student.Study();
                    Console.WriteLine("****************************************");
                    //{
                    //    AbstractStudent studentDecorator = new BaseStudentDecorator();
                    //    studentDecorator.Study();// 学习课程,,在学习前加点东西:付费  要预习
                    //}
                    {
                        //StudentPreviewDecorator studentDecorator = new StudentPreviewDecorator(student);
                        //AbstractStudent studentDecorator = new StudentPreviewDecorator(student);//换成抽象变量
                        //studentDecorator.Study();

                        //student = new StudentHomeworkDecorator(student);

                        student = new StudentPreviewDecorator(student);//原有变量
                        student = new StudentRegDecorator(student);
                        student = new StudentPayDecorator(student);

                        student = new StudentHomeworkDecorator(student);
                        student = new StudentCommentDecorator(student);


                        //student.Study();
                        //学习之后  巩固练习homework
                        //student = new StudentHomeworkDecorator(student);
                        student.Study();
                    }
                }
                //{
                //    AbstractStudent student = new StudentFree()
                //    {
                //        Id = 381,
                //        Name = "候鸟"
                //    };
                //    student.Study();
                //    Console.WriteLine("****************************************");

                //    student = new StudentPreviewDecorator(student);//原有变量
                //    student = new StudentPayDecorator(student);
                //    student.Study();
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }
Example #2
0
 static void Main(string[] args)
 {
     try
     {
         AbstractStudent student = new StudentVip()
         {
             Id   = "1001",
             Name = "tom"
         };
         {
             //student.Show();
         }
         {
             student = new BaseStudentDecorator(student);
             student = new StudentCoreDecorator(student);
             student = new StudentDesignDecorator(student);
             student.Show();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     Console.Read();
 }
Example #3
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("欢迎来到.net高级班vip课程,今天是设计模式的学习");
                AbstractStudent student = new StudentVip()
                {
                    Id   = 381,
                    Name = "秋叶"
                };
                //student.Show();

                //int i = 0;
                //i = 1;
                //AbstractStudent student2 = new BaseStudentDecorator(student);
                //student2.Show();

                student = new BaseStudentDecorator(student);//覆盖了
                //student.Show();

                //AbstractStudent student3 = new StudentCoreDecorator(student);
                //student3.Show();

                student = new StudentPayDecorator(student);

                student = new StudentCoreDecorator(student);
                student = new StudentFrameworkDecorator(student);
                student = new StudentProjectDecorator(student);
                student = new StudentDesignDecorator(student);

                //student = new StudentPayDecorator(student);

                student.Show();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }