public static int stringToInt(String s) throws IllegalArgumentException {
		
		/*
		 * (1) Determine if number should be negative (and starting index for
		 * processing the rest of the String.
		 */
		
		boolean isNegative = false;
		if (s.length() > 1 && s.charAt(0) == '-') {
			isNegative = true;
		}
		
		/*
		 * (2) Iterate over all characters of the string, and construct the resulting
		 * number; if any of the characters is not a digit, throw Exception
		 */
		int x = 0;
		for (int i = (isNegative?1:0); i < s.length(); i++) {
						
			Character c = s.charAt(i);			
			if (Character.isDigit(c)) {							
				x = x  * 10  +  Integer.valueOf(c) - '0';
			}else {
				throw new IllegalArgumentException();
			}

		}
		
		if (isNegative) {
			x = -x;
		}
		
		return x;
	}