Не могу понять, что не так для валидатора. Такой же код в других решениях проходил (смотрел в разделе помощи).
package com.javarush.task.task17.task1711;
import java.util.*;
import java.text.*;
/*
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) {
//start here - начни тут
int id = 0;
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH);
ParsePosition pp = new ParsePosition(0);
switch(args[0]){
case "-c":
synchronized(allPeople){
for(int i = 1; i < args.length; i=i+3){
if(args[i+1].equals("м")){
Person person = Person.createMale(args[i], df.parse(args[i+2], pp));
allPeople.add(person);
System.out.println(allPeople.indexOf(person));
}
else if(args[i+1].equals("ж")){
Person person = Person.createFemale(args[i], df.parse(args[i+2], pp));
allPeople.add(person);
System.out.println(allPeople.indexOf(person));
}
}
}
break;
case "-u":
synchronized(allPeople){
for(int i = 1; i < args.length; i=i+4){
id = Integer.parseInt(args[i]);
allPeople.get(id).setName(args[i+1]);
allPeople.get(id).setBirthDay(df.parse(args[i+3], pp));
if(args[i+2].equals("м")) allPeople.get(id).setSex(Sex.MALE);
else if(args[i+2].equals("ж")) allPeople.get(id).setSex(Sex.FEMALE);
}
}
break;
case "-d":
synchronized(allPeople){
for(int i = 1; i < args.length; i++){
id = Integer.parseInt(args[i]);
allPeople.get(id).setName(null);
allPeople.get(id).setSex(null);
allPeople.get(id).setBirthDay(null);
}
}
break;
case "-i":
synchronized(allPeople){
for(int i = 1; i < args.length; i++){
id = Integer.parseInt(args[i]);
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
Date date = allPeople.get(id).getBirthDay();
String s = allPeople.get(id).getSex() == Sex.MALE ? "м": "ж";
System.out.println(allPeople.get(id).getName()+" "+s+" "+sdf.format(date));
}
}
break;
}
}
}