Example #1
0
        static void Main(string[] args)
        {
            //屏蔽了IDCard类 通过IDCardFactory 创建IDCard类的实例
            //面向抽象编程,抽象接口的实例指向IDCardFactory具体类
            Factory factory = new IDCardFactory();
            Product card1   = factory.Create("小明");
            Product card2   = factory.Create("小红");
            Product card3   = factory.Create("小刚");

            card1.Use();
            card2.Use();
            card3.Use();


            ////面向具体类编程
            //IDCardFactory factory2 = new IDCardFactory();
            //IDCard card11 = (IDCard)factory2.Create("小明");
            //IDCard card22 = (IDCard)factory2.Create("小红");
            //IDCard card33 = (IDCard)factory2.Create("小刚");
            //card11.Use();
            //card22.Use();
            //card33.Use();


            Console.ReadKey();
        }
Example #2
0
        void Start()
        {
            Factory factory = new IDCardFactory();
            Product card1   = factory.create("結城浩");
            Product card2   = factory.create("とむら");
            Product card3   = factory.create("佐藤花子");

            card1.Use();
            card2.Use();
            card3.Use();
        }
Example #3
0
        public static void Main(string[] args)
        {
            Factory factory = new IDCardFactory();
            Product card1   = factory.Create("結城浩");
            Product card2   = factory.Create("とむら");
            Product card3   = factory.Create("佐藤花子");

            card1.Use();
            card2.Use();
            card3.Use();
        }
Example #4
0
        public static void Run()
        {
            framework.Factory factory = new IDCardFactory();
            Product           card1   = factory.create("홍길동");
            Product           card2   = factory.create("이순신");
            Product           card3   = factory.create("강감찬");

            card1.use();
            card2.use();
            card3.use();
        }
Example #5
0
    // Start is called before the first frame update
    void Start()
    {
        AbstractFactory factory = new IDCardFactory();
        AbstractProduct card1   = factory.Create("小明");
        AbstractProduct card2   = factory.Create("小红");
        AbstractProduct card3   = factory.Create("小强");

        card1.Use();
        card2.Use();
        card3.Use();
    }
Example #6
0
    // Start is called before the first frame update
    void Start()
    {
        Factory factory = new IDCardFactory();
        Product card1   = factory.Create("山田");
        Product card2   = factory.Create("小田原");
        Product card3   = factory.Create("勅使河原");

        card1.Use();
        card2.Use();
        card3.Use();
    }
Example #7
0
        static void Main()
        {
            Factory factory = new IDCardFactory();

            IProduct card1 = factory.Create("与謝野晶子");
            IProduct card2 = factory.Create("dice");
            IProduct card3 = factory.Create("owner");

            card1.Use();
            card2.Use();
            card3.Use();
        }
        public void CreateTwoCardAndGetSerialNumberTest()
        {
            var factory = new IDCardFactory ();
            var idCard1 = factory.Create ("John Doe");
            var idCard2 = factory.Create ("iKW HiDARi");
            var idCard3 = factory.Create ("HogeHoge");

            var ownerList = factory.GetOwners ();
            foreach (var item in ownerList)
            {
                Console.WriteLine("No.{0}: {1}",item.Key,item.Value);
            }

            idCard1.Use ();
            idCard2.Use ();
            idCard3.Use ();
        }
Example #9
0
        static void Main(string[] args)
        {
            Factory factory = new IDCardFactory();
            Product card1   = factory.Create("Tom");
            Product card2   = factory.Create("Mike");
            Product card3   = factory.Create("Beth");

            card1.Use();
            card2.Use();
            card3.Use();

            factory.Create("new one");
            factory.Create("Ping");

            foreach (Product product in ((IDCardFactory)factory).GetOwners())
            {
                product.Use();
            }
        }
Example #10
0
 public static void Main( )
 {
     var factory = new IDCardFactory();
     var card1 = factory.CreateProduct( "test" );
     card1.Use();
 }
Example #11
0
 public void CreateIDCardThenUse(string name)
 {
     var factory = new IDCardFactory ();
     var id = factory.Create (name);
     id.Use ();
 }