The Builder Pattern in .NET: Listing 6

Listing 6: Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VSMBuilderPatternDemo.Builder;
 
namespace VSMBuilderPatternDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            BrewMaster brewMeister = new BrewMaster();
            brewMeister.SetBeerBuilder(new AmberAleBuilder());
            brewMeister.BrewBeer();
            Beer amberAle = brewMeister.GetBeer();
            Console.WriteLine(amberAle);
            brewMeister.SetBeerBuilder(new StoutBuilder());
            brewMeister.BrewBeer();
            Beer stout = brewMeister.GetBeer();
            Console.WriteLine(stout);
            Console.ReadLine();
        }
    }
}

About the Author

Eric Vogel is a Senior Software Developer for Red Cedar Solutions Group in Okemos, Michigan. He is the president of the Greater Lansing User Group for .NET. Eric enjoys learning about software architecture and craftsmanship, and is always looking for ways to create more robust and testable applications. Contact him at [email protected].

comments powered by Disqus

Featured

Subscribe on YouTube