Last active
November 1, 2015 22:10
-
-
Save RodrigoLegendre/20679aa4fdda43bb4369 to your computer and use it in GitHub Desktop.
StackOverflow - Q33467177 - MCVE by TheLima
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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