Skip to content

Instantly share code, notes, and snippets.

@RodrigoLegendre
Last active November 1, 2015 22:10
Show Gist options
  • Save RodrigoLegendre/20679aa4fdda43bb4369 to your computer and use it in GitHub Desktop.
Save RodrigoLegendre/20679aa4fdda43bb4369 to your computer and use it in GitHub Desktop.
StackOverflow - Q33467177 - MCVE by TheLima
/*
USE NEGATIVE NUMBERS TO EXIT, IN ANY INPUT
*/
package Q_33467177;
import java.awt.Point;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
/**
*
* @author TheLima <http://stackoverflow.com/users/1253136/thelima>;
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException {
boolean exit = false;
Point[] A = new Point[100];
Scanner in = new Scanner(System.in);
while (!exit) {
System.out.println("Enter index: ");
int i = in.nextInt(); //validate
if (i < 0) {
exit = true;
break;
}
System.out.print("Enter integers x, y to replace: ");
int x = in.nextInt();
if (x < 0) {
exit = true;
break;
}
int y = in.nextInt();
if (y < 0) {
exit = true;
break;
}
A[i] = new Point(x, y);
}
PrintWriter p;
try {
p = new PrintWriter("Project.txt");
for (Point k : A) {
p.println(Arrays.deepToString(A));
}
p.close();
} catch (FileNotFoundException ex) {
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
throw ex;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment