Created
April 17, 2020 12:27
-
-
Save davidelettieri/f041f3b4a3a17a72eec21049a6973e98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface INode | |
{ | |
double Eval(Dictionary<char, double> variablesValue); | |
} | |
public class AddNode : INode | |
{ | |
private readonly INode _left; | |
private readonly INode _right; | |
public AddNode(INode left, INode right) | |
{ | |
_left = left; | |
_right = right; | |
} | |
public double Eval(Dictionary<char, double> variablesValue) => _left.Eval(variablesValue) + _right.Eval(variablesValue); | |
public override string ToString() | |
{ | |
return $"Add({_left},{_right})"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment