Source code for submission s954

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. StringBuffer row = new StringBuffer(br.readLine());
  24.  
  25. ArrayList<String> rows = new ArrayList<String>();
  26.  
  27. while(row.length()>0) {
  28. Integer whiteChar = row.toString().indexOf(" ");
  29. String[] split = row.toString().split(" ");
  30.  
  31. int rowCount = 0;
  32. String text;
  33. if (split.length == 2) {
  34. rowCount = Integer.parseInt(split[0]);
  35. text= split[1];
  36. } else {
  37. rowCount = Integer.parseInt(split[0]);
  38. text= " ";
  39. }
  40.  
  41.  
  42.  
  43. for (int i = 0; i < rowCount; i++) {
  44. String row2 = br.readLine();
  45. String tmp = row2.replace(text, "");
  46. rows.add(tmp);
  47. }
  48. row = new StringBuffer(br.readLine());
  49. }
  50.  
  51. for (String r : rows) {
  52. System.out.println(r);
  53. }
  54.  
  55. }
  56. }
  57.  

Diff to submission s934

Bugs.java

--- c4.s934.cteam124.bugs.java.0.Bugs.java
+++ c4.s954.cteam124.bugs.java.0.Bugs.java
@@ -27,7 +27,18 @@
 
         while(row.length()>0) {
+            Integer whiteChar = row.toString().indexOf(" ");
             String[] split = row.toString().split(" ");
-            int rowCount = Integer.valueOf(split[0]);
-            String text = split[1];
+            
+            int rowCount = 0;
+            String text;
+            if (split.length == 2) {
+                rowCount = Integer.parseInt(split[0]);
+                text= split[1];
+            } else {
+            rowCount = Integer.parseInt(split[0]);
+                text= " ";
+            }
+            
+            
                          
             for (int i = 0; i < rowCount; i++) {