Anonymous
public text v1 · immutableTerm(String term) throws IllegalArgumentException {
double coef;
int exp;
int random = term.indexOf('x');
String[] s = term.split("x");
coef = Double.parseDouble(s[0]);
if (random!=-1){
int carrot = term.indexOf('^');
if (carrot!=-1){
exp = Integer.parseInt(s[1].substring(1));
}
else {exp = 1;}
}
else{exp=0;
}
t = new Pair(coef, exp);
}