fork download
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.*;
  5.  
  6.  
  7. public class Main {
  8. public static void main(String[] args) {
  9. System.out.println("Put the product, use '/' for argument");
  10. ArrayList<Product> list = new ArrayList<>();
  11. Map<Apple, Integer> breakfast = new HashMap<>();
  12. try {
  13. int k = 0;
  14. while (true) {
  15. String s = read.readLine();
  16. if ((s.length() == 0) || (s.matches("[0-9]"))) {
  17. System.out.println("Put the string only");
  18. break;
  19. }
  20. String parts[] = s.split("/");
  21. if (parts[0].equals("Apple")) {
  22. list.add(new Apple(parts[1]));
  23. }
  24. }
  25. } catch (IOException e) {
  26. System.out.println(e.getMessage());
  27. }
  28. for (int i = 0; i < list.size(); i++) {
  29. int k = 0;
  30. if (list.get(i) instanceof Apple) {
  31. Apple a = (Apple) list.get(i);
  32. {
  33. for (int j = 0; j < list.size(); j++) {
  34. if (list.get(j) instanceof Apple) {
  35. Apple b = (Apple) list.get(j);
  36. if(a.getSize().equals(b.getSize())) {
  37. k++;
  38. list.remove(j);
  39. j=j-1;
  40. }
  41. }
  42. }
  43. System.out.println("In this month had eaten " + k + " apple a " + a.getSize() + " size");
  44. }
  45. }
  46. }
  47. }
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:10: error: cannot find symbol
        ArrayList<Product> list = new ArrayList<>();
                  ^
  symbol:   class Product
  location: class Main
Main.java:12: error: cannot find symbol
        Map<Apple, Integer> breakfast = new HashMap<>();
            ^
  symbol:   class Apple
  location: class Main
Main.java:23: error: cannot find symbol
                    list.add(new Apple(parts[1]));
                                 ^
  symbol:   class Apple
  location: class Main
Main.java:31: error: cannot find symbol
            if (list.get(i) instanceof Apple) {
                                       ^
  symbol:   class Apple
  location: class Main
Main.java:32: error: cannot find symbol
                Apple a = (Apple) list.get(i);
                ^
  symbol:   class Apple
  location: class Main
Main.java:32: error: cannot find symbol
                Apple a = (Apple) list.get(i);
                           ^
  symbol:   class Apple
  location: class Main
Main.java:35: error: cannot find symbol
                        if (list.get(j) instanceof Apple) {
                                                   ^
  symbol:   class Apple
  location: class Main
Main.java:36: error: cannot find symbol
                            Apple b = (Apple) list.get(j);
                            ^
  symbol:   class Apple
  location: class Main
Main.java:36: error: cannot find symbol
                            Apple b = (Apple) list.get(j);
                                       ^
  symbol:   class Apple
  location: class Main
9 errors
stdout
Standard output is empty