Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var generator = new Greeting( 
                new OutOfState(
                    new PremiumPlan(
                        new SpecialPlanDisclaimer( 
                            null))));

            var member = new MemberInformation
            {
                Name = "Sally Smith",
                County = "Hartford",
                Plan = "X1234",
                State = "CT",
            };

            generator.GenerateMessage(Console.Out, member);

            Console.WriteLine("---------------");

            member = new MemberInformation
            {
                Name = "John Smith",
                County = "New Haven",
                Plan = "X1234P",
                State = "CT",
            };

            generator.GenerateMessage(Console.Out, member);

            Console.WriteLine("---------------");

            member = new MemberInformation
            {
                Name = "Joan Smith",
                County = "Litchfield",
                Plan = "1234P",
                State = "CT",
            };

            generator.GenerateMessage(Console.Out, member);

            Console.WriteLine("---------------");

            member = new MemberInformation
            {
                Name = "Richard Smith",
                County = "Kings",
                Plan = "1234P",
                State = "NY",
            };

            generator.GenerateMessage(Console.Out, member);
        }
Exemplo n.º 2
0
        public void GenerateMessage(TextWriter writer, MemberInformation member)
        {
            if (IsApplicable(member))
            {
                Write(writer, member);
            }

            if (_next != null)
            {
                _next.GenerateMessage(writer, member);
            }
        }
Exemplo n.º 3
0
 protected abstract bool IsApplicable(MemberInformation member);
Exemplo n.º 4
0
 protected abstract void Write(TextWriter writer, MemberInformation member);
Exemplo n.º 5
0
 protected override bool IsApplicable(MemberInformation member)
 {
     return(true);
 }
Exemplo n.º 6
0
 protected override void Write(TextWriter writer, MemberInformation member)
 {
     writer.WriteLine($"{member.Name},");
     writer.WriteLine("Welcome to our health plan!  We're very happy to have you.");
 }
Exemplo n.º 7
0
 protected override void Write(TextWriter writer, MemberInformation member)
 {
     writer.WriteLine("Since you're an out-of-state member, ...");
 }
Exemplo n.º 8
0
 protected override bool IsApplicable(MemberInformation member)
 {
     return(member.State != "CT");
 }
Exemplo n.º 9
0
 protected override void Write(TextWriter writer, MemberInformation member)
 {
     writer.WriteLine("Since you're a member of our special plan, we need to tell you some extra important information...");
 }
Exemplo n.º 10
0
 protected override bool IsApplicable(MemberInformation member)
 {
     return(member.Plan.StartsWith("X1"));
 }
Exemplo n.º 11
0
 protected override void Write(TextWriter writer, MemberInformation member)
 {
     writer.WriteLine("Your premium of {0} is due on the first of each month.  Please visit our website to set up payments, or call XXX-XXX-XXXX.");
 }