Мозг кипит, помогите найти ошибки
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 {
int id;
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH);
Person person = null;
Sex sex = null;
switch (args[0]) {
case "-c":
synchronized (allPeople) {
for (int i = 1; i < args.length; i+=3) {
String name = args[i];
person.setName(name);
Date birthdate = format.parse(args[i+2]);
sex = args[i+1].equals("м")? Sex.MALE : Sex.FEMALE;
if(sex == Sex.MALE){
person = Person.createMale( name ,birthdate);
allPeople.add(person);
}
if(sex == Sex.FEMALE){
person = Person.createFemale(name , birthdate);
allPeople.add(person);
}
System.out.println(allPeople.indexOf(person));
}
}
break;
case "-u":
synchronized (allPeople) {
for (int i = 1; i < args.length; i+=4) {
id = Integer.parseInt(args[i]);
Person person1 = allPeople.get(id);
String name = args[i+1];
person.setName(name);
if(args[i+3].equals("м")){
person1.setSex(Sex.MALE);
}
else if(args[i+3].equals("ж")){
person1.setSex(Sex.FEMALE);
}
Date birthdate = format.parse(args[i+2]);
person1.setBirthDate(birthdate);
}
}
break;
case "-d":
synchronized (allPeople) {
for (int i = 0; i < args.length; i++) {
id = Integer.parseInt(args[i]);
Person person2 = allPeople.get(id);
person2.setName(null);
person2.setSex(null);
person2.setBirthDate(null);
}
}
break;
case "-i":
synchronized (allPeople) {
for (int i = 1; i < args.length; i++) {
id = Integer.parseInt(args[i]);
Person person3 = allPeople.get(id);
String name = person3.getName();
sex = person3.getSex();
Date birthDate = person3.getBirthDate();
System.out.printf("%s %s %s", name, sex, birthDate);
}
}
break;
}
}
}