コード例 #1
0
        private void BtnEscolherExercito_Click(object sender, RoutedEventArgs e)
        {
            AbstractFactoryExercito factory = null;

            if (sender == BtnEgito)
            {
                factory =
                    AbstractFactoryExercito.CriarFactoryExercito(
                        AbstractFactoryExercito.Nacao.Egito);
            }
            else if (sender == BtnPersia)
            {
                factory =
                    AbstractFactoryExercito.CriarFactoryExercito(
                        AbstractFactoryExercito.Nacao.Persia);
            }
            else if (sender == BtnIndia)
            {
                factory =
                    AbstractFactoryExercito.CriarFactoryExercito(
                        AbstractFactoryExercito.Nacao.India);
            }
            else if (sender == BtnFenicia)
            {
                factory =
                    AbstractFactoryExercito.CriarFactoryExercito(
                        AbstractFactoryExercito.Nacao.Fenicia);
            }

            TelaDeGuerra tg = new TelaDeGuerra();

            tg.FactoryExercito = factory;
            tg.ShowDialog();
        }
コード例 #2
0
        private void BtnEscolherExercito_Click(object sender, RoutedEventArgs e)
        {
            AbstractFactoryExercito factory = null;

            if (sender == BtnEgito)
            {
                //factory =
            }
            else if (sender == BtnPersia)
            {
                factory = new FactoryExercitoPersa();
            }
            else if (sender == BtnIndia)
            {
                factory = new FactoryExercitoIndiano();
            }


            TelaDeGuerra tg = new TelaDeGuerra();

            tg.FactoryExercito = factory;
            tg.ShowDialog();
        }