1 | package PIANOS.datastructures; |
2 | |
3 | public class Equation{ |
4 | |
5 | private Variable[] parameters; |
6 | private String[] equation; |
7 | |
8 | |
9 | public Equation (String[] equation, Variable[] parameters){ |
10 | this.equation = equation; |
11 | this.parameters = parameters; |
12 | } |
13 | |
14 | public String[] getEquation (){ |
15 | String[] toGet = new String[equation.length]; |
16 | for (int i = 0; i < toGet.length; ++i) |
17 | toGet[i] = new String(equation[i]); |
18 | return toGet; |
19 | } |
20 | |
21 | public Variable[] getParameters (){ |
22 | return parameters; |
23 | } |
24 | |
25 | public void setParameters(Variable[] parameters){ |
26 | this.parameters = parameters; |
27 | } |
28 | |
29 | public void setParameters(Variable parameter){ |
30 | Variable[] array = new Variable[1]; |
31 | array[0] = parameter; |
32 | setParameters(array); |
33 | } |
34 | |
35 | public String toString(){ |
36 | String toReturn = ""; |
37 | for (int i = 0; i < equation.length; ++i) |
38 | toReturn += equation[i]; |
39 | toReturn += " parameters: "; |
40 | for(int i=0; i< parameters.length; ++i){ |
41 | toReturn += parameters[i].getName(); |
42 | if (i != parameters.length -1) |
43 | toReturn += ", "; |
44 | } |
45 | return toReturn; |
46 | } |
47 | } |