При отправке на проверку валидатор выдает сообщение:
"Задача не компилируется на сервере!
Ошибка в файле com/javarush/task/task17/task1711/Solution.java в строке : 25
Отсутствует объявление класса, интерфейса или enum-а".
На локальной машине все норм компилится. JDK 14.0.1
package com.javarush.task.task17.task1711;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/*
CRUD 2
*/
public class Solution {
public static volatile List<Person> allPeople = new ArrayList<Person>();
static {
allPeople.add(Person.createMale("Иванов Иван", new Date())); //сегодня родился id=0
allPeople.add(Person.createMale("Петров Петр", new Date())); //сегодня родился id=1
}
public static void main(String[] args) throws ParseException {
//start here - начни тут
switch (args[0]) {
case "-c" -> {
synchronized (Solution.allPeople) {
create(args);
}
}
case "-u" -> {
synchronized (Solution.allPeople) {
update(args);
}
}
case "-d" -> {
synchronized (Solution.allPeople) {
delete(args);
}
}
case "-i" -> {
synchronized (Solution.allPeople) {
info(args);
}
}
}
/* for (Person p : allPeople) {
System.out.println(allPeople.indexOf(p) +
" " +
p.getName() +
" " +
p.getSex() +
" " +
p.getBirthDate());
}*/
}
public static void create(String[] args) throws ParseException {
for (int i = 1; i <= args.length / 3; i++) {
String name = args[i * 3 - 2];
String sexStr = args[i * 3 - 1];
String dateStr = args[i * 3];
Person p = null;
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date bd = dateFormat.parse(dateStr);
if (sexStr.equals("м")) p = Person.createMale(name, bd);
else if (sexStr.equals("ж")) p = Person.createFemale(name, bd);
allPeople.add(p);
System.out.println(allPeople.indexOf(p));
}
}
public static void update(String[] args) throws ParseException {
for (int i = 1; i <= args.length / 4; i++) {
int id = Integer.parseInt(args[i * 4 - 3]);
String name = args[i * 4 - 2];
Person p = null;
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date bd = dateFormat.parse(args[i * 4]);
if (args[i * 4 - 1].equals("м")) p = Person.createMale(name, bd);
else if (args[i * 4 - 1].equals("ж")) p = Person.createFemale(name, bd);
allPeople.set(id, p);
}
}
public static void delete(String[] args) {
for (int i = 1; i < args.length; i++) {
int id = Integer.parseInt(args[i]);
Person p = Person.createMale(null, null);
p.setSex(null);
allPeople.set(id, p);
}
}
public static void info(String[] args) {
for (int i = 1; i < args.length; i++) {
int id = Integer.parseInt(args[i]);
Person p;
p = allPeople.get(id);
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
String sex = null;
switch (p.getSex()) {
case MALE -> sex = "м";
case FEMALE -> sex = "ж";
}
System.out.println(p.getName() +
" " +
sex +
" " +
dateFormat.format(p.getBirthDate()));
}
}
}