Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal interface ICompositePart
- {
- double Evaluate();
- }
- public class Addition : ICompositePart
- {
- public Addition(ICompositePart op1, ICompositePart op2)
- {
- Op1 = op1;
- Op2 = op2;
- }
- public ICompositePart Op1 { get; }
- public ICompositePart Op2 { get; }
- public double Evaluate()
- {
- return Op1.Evaluate() + Op2.Evaluate();
- }
- }
- public class Multiplication : ICompositePart
- {
- public Multiplication(ICompositePart op1, ICompositePart op2)
- {
- Op1 = op1;
- Op2 = op2;
- }
- public ICompositePart Op1 { get; }
- public ICompositePart Op2 { get; }
- public double Evaluate()
- {
- return Op1.Evaluate() * Op2.Evaluate();
- }
- }
- public class Number : ICompositePart
- {
- public Number(int value)
- {
- Value = value;
- }
- public int Value { get; }
- public double Evaluate()
- {
- return Value;
- }
- }
Add Comment
Please, Sign In to add comment