public class VectorObject extends Object
{

private int type;
 // die drei werte eines vektors (bzw ist x der wert eines skalars)
private double x;
private double y;
private double z;
 // alle anderen sachen werden als char gespeichert
private char c;

public static final int DIGIT = 0;	    // ziffer
public static final int DOT = 1;	    // dezimalpunkt
public static final int COMMA = 2;	    // trennzeichen bei den vekoren
public static final int PLUS = 3;	    // ein '+'
public static final int MINUS = 4;	    // ein '-'
public static final int MULT = 5;	    // ein '*'
public static final int L_BRACKET = 6;	    // eine '(' (Left ...)
public static final int R_BRACKET = 7;	    // eine ')' (Right ...)
public static final int L_SQ_BRACKET = 8;   // eine '[' (Left SQuare bracket)
public static final int R_SQ_BRACKET = 9;   // eine ']' (Right SQuare bracket)
public static final int SCALAR = 10;	    // ein skalar
public static final int VECTOR = 11;	    // ein vektor

/*
 * am anfang wird jedes zeichen des eingabestrings als
 * eigenes objekt im Vector gespeichert.  als wert hat
 * es nur seinen char wert (c).
 */
public VectorObject( char c ) throws Exception
{
	super();

	this.c = c;
	
	switch (c) {
		case '+':	type = PLUS; break;
		case '-':	type = MINUS; break;
		case '*':	type = MULT; break;
		case '.':	type = DOT; break;
		case ',':	type = COMMA; break;
		case '(':	type = L_BRACKET; break;
		case ')':	type = R_BRACKET; break;
		case '[':	type = L_SQ_BRACKET; break;
		case ']':	type = R_SQ_BRACKET; break;
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':	type = DIGIT; break;
 // andere zeichen sind nicht zulaessig
		default:	throw new Exception();
	}
		
} // end constructor( char )

/*
 * wird dem constructor ein String uebergeben, wird er als
 * ein skalar gespeichert.
 */
public VectorObject( String x )
{
	super();

	type = SCALAR;
	this.x = Double.parseDouble(x);
} // end constructor( String )

/*
 * werden drei strings uebergeben wird das als vektor
 * interpretiert.
 */
public VectorObject( String x, String y, String z )
{
	super();

	type = VECTOR;
	this.x = Double.parseDouble(x);
	this.y = Double.parseDouble(y);
	this.z = Double.parseDouble(z);
} // end constructor( String, String, String )

/*
 * diese kleinen funktionen machen den umgang mit einem
 * VectorObject viel bequemer.
 */
public int getType()
{
	return type;
}

public boolean isPrefix()
{
	return (type == PLUS) | (type == MINUS);
}
public boolean isOperator()
{
	return (type == PLUS) | (type == MINUS) | (type == MULT);
}
public boolean isDigit()
{
	return (type == DIGIT);
}

public boolean isDot()
{
	return (type == DOT);
}

public boolean isLBr()
{
	return (type == L_BRACKET);
}

public boolean isRBr()
{
	return (type == R_BRACKET);
}

public boolean isVector()
{
	return (type == VECTOR);
}

public char getC()
{
	return c;
}

public double getX()
{
	return x;
}

public double getY()
{
	return y;
}

public double getZ()
{
	return z;
}

} // end class VectorObject