I keep getting an error message saying I have an input mismatch. I just can't seem to figure out where the mismatch is happening. Does somebody see what I'm doing wrong? The other question I have is I want to add +1 to the result.x for each item that comes in. I thought I would to that by setting x = 1 at the beginning of my coordinate class but it doesn't work. Is this not the way to do it? Or am I forgetting something? Sorry pretty new to programming so I hope one of you can help!
This is the input: 5,4 4,5 8,7=6,3 3,2 9,6 4,3=7,6=9,8=5,5 7,8 6,5 6,4 I've first add my main class and below it my second class.
package pirate2;
import java.util.Scanner;
import ui.UIAuxiliaryMethods;
import java.io.PrintStream;
class Pirate4 {
PrintStream out;
Pirate4() {
out = new PrintStream(System.out);
}
Coordinate readCoordinate(Scanner coordinateInputScanner) {
Coordinate result = new Coordinate();
coordinateInputScanner.useDelimiter(" |,");
while (coordinateInputScanner.hasNext()) {
result.x = 1 + coordinateInputScanner.nextInt(); // not the right solution for +1
result.y = coordinateInputScanner.nextInt();
System.out.println(result.x + "\t" + result.y);
}
return result;
}
void start() {
Scanner fileScanner = UIAuxiliaryMethods.askUserForInput().getScanner();
while (fileScanner.hasNext()) {
fileScanner.useDelimiter("=");
String coordinateRowInput = fileScanner.next();
Scanner coordinateInputScanner = new Scanner(coordinateRowInput);
readCoordinate(coordinateInputScanner);
}
}
public static void main(String[] argv) {
new Pirate4().start();
}
}
package pirate2;
class Coordinate {
int x;
int y;
Coordinate() {
x = 0;
y = 0;
}
}