fork download
  1. import java.io.IOException;
  2. import java.io.Reader;
  3. import java.util.*;
  4. import java.text.*;
  5.  
  6.  
  7. public class ImplEmployeeParser implements EmployeeParser {
  8.  
  9. @Override
  10. public List<Employee> parse(Reader reader) throws IOException,NumberFormatException {
  11. HashMap<Integer,Employee> sets = new HashMap<Integer,Employee>();
  12.  
  13. int ch;
  14. char c;
  15. boolean hasQuoate = false;
  16. StringBuilder token = new StringBuilder();
  17. ArrayList<String> tokens = new ArrayList<String>();
  18. while(true)
  19. {
  20. ch = reader.read();
  21. c = (char)ch;
  22. if(c == '“')
  23. {
  24. hasQuoate = true;
  25. }
  26. else if(hasQuoate && c == '”')
  27. {
  28. if(token.length() > 0)
  29. tokens.add(token.toString());
  30. token = new StringBuilder();
  31. hasQuoate = false;
  32. }
  33. else if(c == ',')
  34. {
  35. if(token.length() > 0)
  36. tokens.add(token.toString());
  37. token = new StringBuilder();
  38. }
  39. else if(c == '\r' || c == '\n' || ch == -1)
  40. {
  41. if(token.length() > 0)
  42. tokens.add(token.toString());
  43. token = new StringBuilder();
  44. if(tokens.size() == 3)
  45. {
  46. Integer id = Integer.parseInt(tokens.get(0));
  47. sets.put(id,new Employee(id,tokens.get(1),Integer.parseInt(tokens.get(2))));
  48. tokens.clear();
  49. }
  50. if(ch == -1)
  51. break;
  52. }
  53. else if(c != ' ')
  54. {
  55. token.append(c);
  56. }
  57. }
  58.  
  59. return new ArrayList<Employee>(sets.values());
  60. }
  61. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:7: error: class ImplEmployeeParser is public, should be declared in a file named ImplEmployeeParser.java
public class ImplEmployeeParser implements EmployeeParser {
       ^
Main.java:7: error: cannot find symbol
public class ImplEmployeeParser implements EmployeeParser {
                                           ^
  symbol: class EmployeeParser
Main.java:10: error: cannot find symbol
	public List<Employee> parse(Reader reader) throws IOException,NumberFormatException {
	            ^
  symbol:   class Employee
  location: class ImplEmployeeParser
Main.java:11: error: cannot find symbol
		HashMap<Integer,Employee> sets = new HashMap<Integer,Employee>();
		                ^
  symbol:   class Employee
  location: class ImplEmployeeParser
Main.java:11: error: cannot find symbol
		HashMap<Integer,Employee> sets = new HashMap<Integer,Employee>();
		                                                     ^
  symbol:   class Employee
  location: class ImplEmployeeParser
Main.java:47: error: cannot find symbol
					sets.put(id,new Employee(id,tokens.get(1),Integer.parseInt(tokens.get(2))));
					                ^
  symbol:   class Employee
  location: class ImplEmployeeParser
Main.java:59: error: cannot find symbol
		return new ArrayList<Employee>(sets.values());
		                     ^
  symbol:   class Employee
  location: class ImplEmployeeParser
Main.java:9: error: method does not override or implement a method from a supertype
	@Override
	^
8 errors
stdout
Standard output is empty