Example #1
0
 public object Compress()
 {
     if (_childs[0] is SimpleElement)
     {
         SimpleElement compressed = new SimpleElement();
         if (currentState.IsDown)
         {
             compressed.Turn();
         }
         for (int i = 0; i < 4; i++)
         {
             compressed.SetChild(i, _childs[i].Compress());
         }
         return(compressed);
     }
     else
     {
         Composite compressed = new Composite();
         for (int i = 0; i < 4; i++)
         {
             compressed.SetChild(i, _childs[i].Compress());
         }
         if (currentState.IsDown)
         {
             compressed.Turn();
         }
         return(compressed);
     }
 }
Example #2
0
        public IElement Clone()
        {
            IElement clone = new SimpleElement();

            if (currentState.IsDown)
            {
                clone.Turn();
            }
            return(clone);
        }