Задачу у меня проходит по условию, причем условие странное какое то,
так в чем ошибка?
package com.javarush.task.task19.task1916;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class Solution {
public static List<LineItem> lines = new ArrayList<LineItem>();
public static void main(String[] args) throws IOException {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
String file1 = buffer.readLine();
String file2 = buffer.readLine();
buffer.close();
ArrayList<String> list1 = new ArrayList<String>();
ArrayList<String> list2 = new ArrayList<String>();
arrayCreate(file1, file2, list1, list2);
boolean stoper = list1.size() >= list2.size() ? true : false;
int massiv, dopolMassiv;
if (stoper == true) {
massiv = list2.size();
dopolMassiv = list1.size();
} else {
massiv = list1.size();
dopolMassiv = list2.size();
}
for (int i=0; i<massiv; i++) {
if (list1.get(i).equals(list2.get(i))) {
lines.add(new LineItem(Type.SAME, list1.get(i)));
} else {
boolean count = false;
for (int j=0; j<list1.size(); j++) {
if (list2.get(i).equals(list1.get(j))) {
count = true;
}
}
if (count == false) {
lines.add(new LineItem(Type.REMOVED, list1.get(i)));
} else {
lines.add(new LineItem(Type.ADDED, list2.get(i)));
}
}
}
if (stoper == true) {
for (int i = massiv; i < dopolMassiv; i++) {
lines.add(new LineItem(Type.REMOVED, list1.get(i)));
}
}
if (stoper == false) {
for (int i = massiv; i < dopolMassiv; i++) {
lines.add(new LineItem(Type.ADDED, list2.get(i)));
}
}
for (int i = 0; i < lines.size(); i++) {
System.out.println(lines.get(i).type + " " + lines.get(i).line);
}
}
public static enum Type {
ADDED, //добавлена новая строка
REMOVED, //удалена строка
SAME //без изменений
}
public static class LineItem {
public Type type;
public String line;
public LineItem(Type type, String line) {
this.type = type;
this.line = line;
}
}
public static void arrayCreate(String file1, String file2, ArrayList<String> list1, ArrayList<String> list2) throws IOException {
BufferedReader reader1 = new BufferedReader(new FileReader(file1));
BufferedReader reader2 = new BufferedReader(new FileReader(file2));
while (reader1.ready()) {
String str = reader1.readLine();
list1.add(str);
}
while (reader2.ready()) {
String str = reader2.readLine();
list2.add(str);
}
reader1.close();
reader2.close();
}
}