Exemplo n.º 1
0
        static void Main(string[] args)
        {
            StartNumber startNUmber                                  = new StartNumber(5);
            IFormula    startMulResult                               = new MulDecorator(startNUmber, 2);
            IFormula    addAndStartMulResult                         = new AddDecorator(startMulResult, 100);
            IFormula    divAndAddAndStartMulResult                   = new DivDecorator(addAndStartMulResult, 12);
            IFormula    subAndDivAndaddAndStartMulResult             = new SubDecorator(divAndAddAndStartMulResult, 3);
            IFormula    mulAndSubAnddivAndaddAndStartMulResult       = new MulDecorator(subAndDivAndaddAndStartMulResult, 4);
            IFormula    addAndMulAndSubAnddivAndaddAndStartMulResult = new AddDecorator(mulAndSubAnddivAndaddAndStartMulResult, 7);

            Console.WriteLine(addAndMulAndSubAnddivAndaddAndStartMulResult.GetFormula());
            Console.WriteLine(addAndMulAndSubAnddivAndaddAndStartMulResult.GetResult());

            startNUmber.ModifyNumber(30);

            Console.WriteLine(addAndMulAndSubAnddivAndaddAndStartMulResult.GetFormula());
            Console.WriteLine(addAndMulAndSubAnddivAndaddAndStartMulResult.GetResult());
        }
Exemplo n.º 2
0
 public override double GetResult()
 {
     return(StartNumber.GetResult() * AdditionalNumber);
 }
Exemplo n.º 3
0
 public override string GetFormula()
 {
     return(StartNumber.GetFormula() + " * " + AdditionalNumber.ToString());
 }