Source code for submission s914

Go to diff to previous submission

Bugs.java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package bugs;
  6.  
  7.  
  8. import java.io.BufferedReader;
  9. import java.io.IOException;
  10. import java.io.InputStreamReader;
  11. import java.util.ArrayList;
  12.  
  13. /**
  14.  *
  15.  * @author student
  16.  */
  17. public class Bugs {
  18.  
  19. /**
  20.   * @param args the command line arguments
  21.   */
  22. public static void main(String[] args) throws IOException {
  23. String row = br.readLine();
  24.  
  25. ArrayList<String> rows = new ArrayList<String>();
  26.  
  27. while(!row.equals("")) {
  28. String[] split = row.split(" ");
  29. int rowCount = Integer.valueOf(split[0]);
  30. String text = split[1];
  31.  
  32. for (int i = 0; i < rowCount; i++) {
  33. String row2 = br.readLine();
  34. String tmp = row2.replace(text, "");
  35. rows.add(tmp);
  36. }
  37. row = br.readLine();
  38. }
  39.  
  40. for (String r : rows) {
  41. System.out.println(r);
  42. }
  43.  
  44. }
  45. }
  46.  

Diff to submission s889

Bugs.java

--- c4.s889.cteam124.bugs.java.0.Bugs.java
+++ c4.s914.cteam124.bugs.java.0.Bugs.java
@@ -7,10 +7,7 @@
 
 import java.io.BufferedReader;
-import java.io.Reader;
-import java.io.StringReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Scanner;
 
 /**
@@ -23,8 +20,7 @@
      * @param args the command line arguments
      */
-    public static void main(String[] args) {
-        
-        Scanner scanner = new Scanner(System.in);
-        String row = scanner.nextLine();
+    public static void main(String[] args) throws IOException {
+        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+        String row = br.readLine();
     
         ArrayList<String> rows = new ArrayList<String>();   
@@ -32,14 +28,13 @@
         while(!row.equals("")) {
             String[] split = row.split(" ");
-            int rowCount = Integer.parseInt(split[0]);
+            int rowCount = Integer.valueOf(split[0]);
             String text = split[1];
                          
             for (int i = 0; i < rowCount; i++) {
-                String row2 = scanner.nextLine();
+                String row2 = br.readLine();
                 String tmp = row2.replace(text, "");
-                //System.out.println(row2);
                 rows.add(tmp);
             }
-            row = scanner.nextLine();
+            row = br.readLine();
         }