All pastes #339121 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-02-03 21:32 UTC
rendered paste body
import java.util.*;

public class FloatingParser {
	String InputString;			// The complete input string.
	String [ ] str = new String[5];	// Holds each of the substrings
// of InputString.
	int [ ] CommaPosition = new int[4];	// Positions of the commas.
	float [ ] f = new float[5];		// The five float-pt values.
	
	char[] ValidChars = {'+', '-', '.','1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};

	public FloatingParser() {
	}

	public FloatingParser(String s) {
		InputString = s;		// Accept the comma-delimited string.

		int j = 0;			// Position from within the comma
						// delimited string from where the
						// next substring is going to start.

		// Extract the first four substrings from the comma-delimited string.
		for (int i = 0; i < 4; i++)
		{
			// Find the position for the next comma.
			CommaPosition[i] = InputString.indexOf(",", j);

			// Extract the next substring.
			str[i] = InputString.substring(j, CommaPosition[i]).trim();

			// Update the start position for the next substring.
			j = CommaPosition[i] + 1;
		}
		// Extract the last substring.
		str[4] = InputString.substring(j) + 1;
	}
	
	public boolean FloatingConvert(int i) {
		String s = str[i];
		
		List foo = Arrays.asList(ValidChars);
		
		System.out.println(foo.get(0));
		
		System.out.println((Object) s.charAt(0));
		
		//System.out.println(Arrays.asList(ValidChars).contains((Object) s.charAt(0)));
		
		for (int c = 0; c < s.length(); c++) {
			//if (Arrays.asList(ValidChars).contains((Object) s.charAt(c)) == false)
			//	return false;
		}
		f[i] = Float.parseFloat(s);
		return true;
	}
	
	public float GetFloatingValue(int i) {
		return 0.0f; // FOR NOW!!
	
	}
}