Commit 75718947275770e2a462647891d516f59c356a38

Authored by Imanol-Mikel Barba Sabariego
1 parent 68ecc41e

git-svn-id: svn://imanolbarba.net/PAD@14 c2ee353e-ed0d-4329-bf56-03aec153487f

readline/bin/pad/prac1/Console.class
No preview for this file type
readline/bin/pad/prac1/EditableBufferedReader.class
No preview for this file type
readline/src/pad/prac1/Console.java
@@ -27,6 +27,7 @@ public class Console implements Observer @@ -27,6 +27,7 @@ public class Console implements Observer
27 scanner.findWithinHorizon(pattern,0); 27 scanner.findWithinHorizon(pattern,0);
28 numCols = Integer.parseInt(scanner.match().group(2)); 28 numCols = Integer.parseInt(scanner.match().group(2));
29 numRows = Integer.parseInt(scanner.match().group(1)); 29 numRows = Integer.parseInt(scanner.match().group(1));
  30 + scanner.close();
30 } 31 }
31 32
32 public Coordinate getCurrentPos() 33 public Coordinate getCurrentPos()
@@ -37,8 +38,10 @@ public class Console implements Observer @@ -37,8 +38,10 @@ public class Console implements Observer
37 Pattern pattern = Pattern.compile("(\\d+);(\\d+)"); 38 Pattern pattern = Pattern.compile("(\\d+);(\\d+)");
38 Scanner scanner = new Scanner(System.in); 39 Scanner scanner = new Scanner(System.in);
39 scanner.findWithinHorizon(pattern,0); 40 scanner.findWithinHorizon(pattern,0);
40 - return new Coordinate(Integer.parseInt(scanner.match().group(2)),  
41 - Integer.parseInt(scanner.match().group(1))); 41 + int x = Integer.parseInt(scanner.match().group(2));
  42 + int y = Integer.parseInt(scanner.match().group(1));
  43 + scanner.close();
  44 + return new Coordinate(x,y);
42 } 45 }
43 46
44 public void moveCursorTo(Coordinate xy) 47 public void moveCursorTo(Coordinate xy)
readline/src/pad/prac1/EditableBufferedReader.java
@@ -108,6 +108,7 @@ public class EditableBufferedReader extends BufferedReader @@ -108,6 +108,7 @@ public class EditableBufferedReader extends BufferedReader
108 line.toggleMode(); 108 line.toggleMode();
109 break; 109 break;
110 } 110 }
  111 + scanner.close();
111 return; 112 return;
112 } 113 }
113 else if(scanner.findWithinHorizon("O?", 0).length() > 0) 114 else if(scanner.findWithinHorizon("O?", 0).length() > 0)
@@ -124,8 +125,10 @@ public class EditableBufferedReader extends BufferedReader @@ -124,8 +125,10 @@ public class EditableBufferedReader extends BufferedReader
124 line.setCursorTo(line.length()+1); 125 line.setCursorTo(line.length()+1);
125 break; 126 break;
126 } 127 }
  128 + scanner.close();
127 return; 129 return;
128 } 130 }
  131 + scanner.close();
129 } 132 }
130 else 133 else
131 { 134 {
@@ -147,6 +150,7 @@ public class EditableBufferedReader extends BufferedReader @@ -147,6 +150,7 @@ public class EditableBufferedReader extends BufferedReader
147 line.addChar((char)character); 150 line.addChar((char)character);
148 break; 151 break;
149 } 152 }
  153 + scanner.close();
150 return; 154 return;
151 } 155 }
152 } 156 }