Help me find what I can't see. After failing I saw other people's code and found them to be quite similar to mine and still mine doesn't pass a single requirement
package com.codegym.task.task17.task1711;
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<>();
static {
allPeople.add(Person.createMale("Donald Chump", new Date())); // id=0
allPeople.add(Person.createMale("Larry Gates", new Date())); // id=1
}
public static void main(String[] args) throws Exception {
SimpleDateFormat date = new SimpleDateFormat("MMM dd yyyy");
switch (args[0]) {
case "-c":
synchronized (allPeople) {
int i = 1;
while (i < args.length) {
Date date1 = date.parse(args[i + 2]);
String name = args[i];
Sex sex = args[i + 1].equals("m") ? Sex.MALE : Sex.FEMALE;
if (sex.equals(Sex.FEMALE))
allPeople.add(Person.createFemale(name, date1));
else
allPeople.add(Person.createMale(name, date1));
i += 3;
System.out.println(allPeople.size() - 1);
}
}
break;
case "-u":
int x = 1;
synchronized (allPeople) {
while (x < args.length) {
Date date2 = date.parse(args[x + 3]);
Sex sex1 = args[x + 2].equals("m") ? Sex.MALE : Sex.FEMALE;
String name1 = args[x + 1];
allPeople.get(Integer.parseInt(args[x])).setBirthDate(date2);
allPeople.get(Integer.parseInt(args[x])).setName(name1);
allPeople.get(Integer.parseInt(args[x])).setSex(sex1);
x += 4;
}
}
break;
case "-d":
int c = 1;
synchronized (allPeople) {
while (c < args.length) {
Person temp = allPeople.get(c);
temp.setSex(null);
temp.setName(null);
temp.setBirthDate(null);
allPeople.set(c, temp);
c++;
}
}
break;
case "-i":
int j = 1;
synchronized (allPeople) {
while (j < args.length) {
Person temp1 = allPeople.get(j);
Sex sexy = temp1.getSex();
String name2 = temp1.getName();
SimpleDateFormat modifyDate = new SimpleDateFormat("MMM dd yyyy", Locale.ENGLISH);
System.out.println
(temp1.getName() + " " + (temp1.getSex().equals(Sex.MALE) ? "m" : "f")
+ " " + modifyDate.format(temp1.getBirthDate()));
j++;
}
}
break;
}
}
}