Advertisement
cupertinoCSstruggle1

20x20?

Feb 3rd, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. public class EraseProjectPKagranaPeriod3 {
  5.  
  6. Scanner in = null;
  7. private String[][] grid = new String[20][20];
  8. private int xPos, yPos;
  9.  
  10. public static void main(String[] args) {
  11. EraseProjectPKagranaPeriod3 e = new EraseProjectPKagranaPeriod3();
  12. System.out.println(" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19" + "\n");
  13. e.loadFile();
  14. e.erase();
  15. }
  16.  
  17. public void loadFile() {
  18. File inFile = new File("digital.txt");
  19.  
  20. try{
  21. in = new Scanner(inFile);
  22. }catch(FileNotFoundException e){
  23. System.out.println(e.getMessage());
  24. }
  25.  
  26. int firstNum = in.nextInt();
  27.  
  28. while(in.hasNext()) {
  29. int row = in.nextInt();
  30. int col = in.nextInt();
  31. grid[row-1][col-1] = "@";
  32.  
  33. } // end of while-loop
  34.  
  35. for (int i = 0; i < grid.length; i++) {
  36. for (int j = 0; j < grid.length; j++) {
  37. if(grid[i][j] != "@") {
  38. grid[i][j] = "-";
  39. }
  40. }
  41. } // end of outer for-loop
  42.  
  43. // for printing
  44. for (int i = 0; i < grid.length; i++) {
  45. System.out.print( (i+1) + " ");
  46. for (int j = 0; j < grid[i].length; j++) {
  47.  
  48. System.out.printf("%3s", grid[i][j]);
  49. }
  50. System.out.println();
  51. } // end of outer for-loop
  52. } // end of method
  53.  
  54. public void erase() {
  55. Scanner input = new Scanner(System.in);
  56.  
  57. System.out.print("\nEnter y coordinate of point to erase: ");
  58. yPos = input.nextInt();
  59. System.out.print("Enter x coordinate of point to erase: ");
  60. xPos = input.nextInt();
  61. }
  62.  
  63. public void move() {
  64. /*
  65. If the element at (xPos, yPos) is part of an object
  66. then you will want to erase that entire object
  67.  
  68. */
  69. }
  70.  
  71. }// end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement