Exemplo n.º 1
0
        public Character GetCharacter(char key)
        {
            // Uses "lazy initialization"
            Character character = null;

            if (_characters.ContainsKey(key))
            {
                character = _characters[key];
            }
            else
            {
                switch (key)
                {
                case 'A': character = new CharacterA(); break;

                case 'B': character = new CharacterB(); break;

                //...
                case 'Z': character = new CharacterZ(); break;
                }
                _characters.Add(key, character);
            }

            return(character);
        }
Exemplo n.º 2
0
        public Character GetCharacter(char key)
        {
            // Utiliza "inicialización perezosa"

            Character character = null;

            if (_characters.ContainsKey(key))
            {
                character = _characters[key];
            }
            else
            {
                switch (key)
                {
                case 'A': character = new CharacterA(); break;

                case 'B': character = new CharacterB(); break;
                //...

                case 'Z': character = new CharacterZ(); break;
                }
                _characters.Add(key, character);
            }
            return(character);
        }
Exemplo n.º 3
0
        public Character GetCharacter(char key)
        {
            // Uses "lazy initialization"
            Character character = null;
            if (this.characters.ContainsKey(key))
            {
                character = this.characters[key];
            }
            else
            {
                switch (key)
                {
                    case 'A':
                        character = new CharacterA();
                        break;
                    case 'B':
                        character = new CharacterB();
                        break;

                    case 'Z':
                        character = new CharacterZ();
                        break;
                }

                this.characters.Add(key, character);
            }

            return character;
        }
Exemplo n.º 4
0
        public Character GetCharacter(char key)
        {
            Character character = null;

            if (_characters.ContainsKey(key))
            {
                character = _characters[key];
            }
            else
            {
                switch (key)
                {
                case 'A': character = new CharacterA();
                    break;

                case 'B': character = new CharacterB();
                    break;

                default:
                    // This is wrong, but I'm not going to create Character classes for all the letters.
                    character = new CharacterA();
                    break;
                }
                _characters.Add(key, character);
            }
            return(character);
        }
Exemplo n.º 5
0
 public Character GetCharacter(char key)
 {
   // Uses "lazy initialization"
   Character character = characters[key] as Character;
   if (character == null)
   {
     switch (key)
     {
       case 'A': character = new CharacterA(); break;
       case 'B': character = new CharacterB(); break;
         //...
       case 'Z': character = new CharacterZ(); break;
     }
     characters.Add(key, character);
   }
   return character;
 }
Exemplo n.º 6
0
        public Character GetCharacter(char key)
        {
            Character character = characters[key] as Character;

            if (character == null)
            {
                switch (key)
                {
                case 'A': character = new CharacterA(); break;

                case 'B': character = new CharacterB(); break;

                case 'Z': character = new CharacterZ(); break;
                }
                characters.Add(key, character);
            }
            return(character);
        }
Exemplo n.º 7
0
        public Character GetCharacter(char key)
        {
            // Uses "lazy initialization"
            Character character = characters[key] as Character;

            if (character == null)
            {
                switch (key)
                {
                case 'A': character = new CharacterA(); break;

                case 'B': character = new CharacterB(); break;

                //...
                case 'Z': character = new CharacterZ(); break;
                }
                characters.Add(key, character);
            }
            return(character);
        }
            public Character GetCharacter(char key)
            {
                Character character = null;

                if (_characters.ContainsKey(key))
                {
                    character = _characters[key];
                }
                else
                {
                    switch (key)
                    {
                    case 'A': character = new CharacterA(); break;

                    case 'B': character = new CharacterB(); break;

                    case 'Z': character = new CharacterZ(); break;
                    }
                    _characters.Add(key, character);
                }
                return(character);
            }