C
cbmeeks
I'm working on a project that deals with some algebra. Or, actually,
just math in general. It could eventually work it's way up to more
advanced math, analytics, etc.
Anyway, I'm looking for ideas on how to store the actual formulas
using classes.
For example:
class X
{
public Value;
}
class Y
{
public Value;
}
X x = new X();
X.Value = 10;
Y y = new Y();
Y.Value = 20;
Now, I want to store this formula:
x.Value + y.Value * 2
Which should give the value of 60.
Hope that makes sense. I thought about having a Formula class with a
List of classes and then build the formula when needed. Taking care
to add special classes like "multiply", etc but I don't think I like
that idea.
I also thought about storing a string somehow and then just parsing
the string and substitute keyword for classes.
Any suggestions?
Thanks
just math in general. It could eventually work it's way up to more
advanced math, analytics, etc.
Anyway, I'm looking for ideas on how to store the actual formulas
using classes.
For example:
class X
{
public Value;
}
class Y
{
public Value;
}
X x = new X();
X.Value = 10;
Y y = new Y();
Y.Value = 20;
Now, I want to store this formula:
x.Value + y.Value * 2
Which should give the value of 60.
Hope that makes sense. I thought about having a Formula class with a
List of classes and then build the formula when needed. Taking care
to add special classes like "multiply", etc but I don't think I like
that idea.
I also thought about storing a string somehow and then just parsing
the string and substitute keyword for classes.
Any suggestions?
Thanks