All pastes #420490 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-02 05:13 UTC
rendered paste body
Term(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);
    }