Recht mühevoll einen Code zusammengebastelt und irgendwie funktioniert die Fehlerabfrage nicht....ich komm leider nicht drauf wo der Hund begraben liegt :cry:
Also wenn ich zB die Punkte mit Koordinaten (6,9) (5,2) (21,7) eingebe und dann mit "=" terminiere kommt immer "FALSCHE EINGABE" was aber nicht sein sollte.
Vielleicht könnte mir wer helfen, da ich im moment ein wenig anstehe.
Danke im Vorraus
Code:
import eprog.*;
import java.util.*;
import java.awt.geom.*;
public class Grml extends EprogIO {
static boolean wrongInput = false;
protected void betweenMinMax(){
Vector points = new Vector();
if (points.size() < 3 || points.size() > 15)
wrongInput = true;
}
static Point2D.Double parseInput (String input){
double x=0, y=0;
StringTokenizer st = new StringTokenizer(input, "(" + x + "," + y + ")");
int pos = 0;
while (st.hasMoreTokens()) {
String token = st.nextToken();
switch (pos) {
case 1: if(!token.equals("(")) wrongInput = true;pos++;break;
case 2: x = Double.parseDouble(token);
if(x < -100 || x > 100) wrongInput = true;pos++;break;
case 3: if (!token.equals(",")) wrongInput = true;pos++;break;
case 4: y = Double.parseDouble(token);
if(y < -100 || y > 100) wrongInput = true;pos++;break;
case 5: if (!token.equals(")")) wrongInput = true;pos++;break;
}
}
return new Point2D.Double(x,y);
}
public static void main(String[] args) throws EprogException {
Point2D.Double P = new Point2D.Double();
Vector points = new Vector();
String input = new String();
input = EprogIO.readWord();
while (!input.equals("=")){
input = EprogIO.readWord();
}
try {
Point2D.Double currentPoint;
points.add(currentPoint = parseInput(input));
if( P != null)
if(currentPoint.equals(P))
wrongInput = true;
P = currentPoint;
} catch (Exception e) {
wrongInput = true;
}
if(wrongInput = true)
EprogIO.println("FALSCHE EINGABE");
else
EprogIO.println("YEAHH BABY");
}
}
Also wenn ich zB die Punkte mit Koordinaten (6,9) (5,2) (21,7) eingebe und dann mit "=" terminiere kommt immer "FALSCHE EINGABE" was aber nicht sein sollte.
Vielleicht könnte mir wer helfen, da ich im moment ein wenig anstehe.
Danke im Vorraus