ВРоде бы учёл всё, но валидатор ругается на REMOVED. "Убедись, что список lines в нужных местах содержит операции REMOVED c нужными строками".
Подскажете где ошибка?
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 {
ArrayList<String> fileList1 = new ArrayList<>();
ArrayList<String> fileList2 = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file1 = reader.readLine();
String file2= reader.readLine();
reader.close();
BufferedReader bufferedReader1 = new BufferedReader(new FileReader(file1));
BufferedReader bufferedReader2 = new BufferedReader(new FileReader(file2));
while (bufferedReader1.ready() || bufferedReader2.ready()) {
fileList1.add(bufferedReader1.readLine());
fileList2.add(bufferedReader2.readLine());
}
bufferedReader1.close();
bufferedReader2.close();
if (fileList1.size()!=fileList2.size()) {
if (fileList1.size()>fileList2.size()) {
int count = fileList1.size()-fileList2.size();
while (count!=0) {
fileList2.add("");
count--;
}
} else if(fileList1.size()<fileList2.size()) {
int count1 = fileList2.size()-fileList1.size();
while (count1!=0) {
fileList1.add("");
count1--;
}
}
}
for (int i=0;i<fileList1.size();i++) {
for (int j=0;j<fileList2.size();j++) {
if (fileList1.get(i).equals(fileList2.get(j))) {
lines.add(new LineItem(Type.SAME, fileList1.get(i)));
} else if (fileList1.get(i).equals("")) {
lines.add(new LineItem(Type.ADDED, fileList2.get(j)));
} else if (fileList2.get(j).equals("")) {
lines.add(new LineItem(Type.REMOVED, fileList1.get(i)));
}
}
}
}
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;
}
}
}