private MultiplyDivideLayer ParseMultiplyDivideLayerFromElements()
        {
            MultiplyDivideLayer layer = new MultiplyDivideLayer();
            if (ContainsType(elements, typeof(MultiplyElement), typeof(DivideElement)))
            {
                List<IElement> els = new List<IElement>(elements);

                while (els.Count > 0)
                    AddFirstToLayerAndDeleteFromList(layer, els);
                return layer;
            }
            if(ContainsType(elements, typeof(ExpElement)))
            {
                ILayer factor, exponent;
                ParseMiddleOperatorType(new List<IElement>(elements), typeof(ExpElement), out factor, out exponent);

                PowerLayer powerLayer = new PowerLayer();
                powerLayer.BaseOfPower = new NumberLayer(10);
                powerLayer.Exponent = exponent;

                layer.Factors.Add(factor);
                layer.Factors.Add(powerLayer);
                return layer;
            }
            return layer;
        }
        private PowerLayer ParsePowerLayerFromElements()
        {
            PowerLayer layer = new PowerLayer();

            ILayer baseOfPower, exponent;
            ParseMiddleOperatorType(new List<IElement>(elements), typeof(PowerElement), out baseOfPower, out exponent);
            layer.BaseOfPower = baseOfPower;
            layer.Exponent = exponent;

            return layer;
        }
Exemplo n.º 3
0
 public void Power(Term exponent)
 {
     PowerLayer powerLayer = new PowerLayer();
     powerLayer.Exponent = exponent.TopLayer;
     powerLayer.BaseOfPower = topLayer;
     topLayer = powerLayer;
 }