Can anyone help please?
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 {
// Start here
switch (args[0]) {
case "-c":
synchronized (allPeople) {
for (int n = 1, s = 2, d = 3; n < args.length; n = n+3, s = s+3, d = d+3) {
if (args[s].equals("m")) {
allPeople.add(Person.createMale(args[n], new SimpleDateFormat("MM dd yyyy").parse(args[d])));
} else {
allPeople.add(Person.createFemale(args[n], new SimpleDateFormat("MM dd yyyy").parse(args[d])));
}
System.out.println(allPeople.size() - 1);
}
}
break;
case "-u":
synchronized (allPeople) {
for (int i = 1, n = 2, s = 3, d = 4; i < args.length; i = i+4, n = n+4, s = s+4, d = d+4) {
int index = Integer.parseInt(args[i]);
Person person = allPeople.get(index);
person.setName(args[n]);
person.setBirthDate(new SimpleDateFormat("MM dd yyyy").parse(args[d]));
if (args[s].equals("m")) {
person.setSex(Sex.MALE);
} else {
person.setSex(Sex.FEMALE);
}
}
}
break;
case "-d":
synchronized (allPeople) {
for (int i = 1; i < args.length; i++) {
int index = Integer.parseInt(args[i]);
Person person = allPeople.get(index);
person.setName(null);
person.setSex(null);
person.setBirthDate(null);
}
}
case "-i":
synchronized (allPeople) {
for (int i = 1; i < args.length; i++) {
int index = Integer.parseInt(args[i]);
Person person = allPeople.get(index);
String name = person.getName();
String sex;
if (person.getSex() == Sex.MALE) {
sex = "m";
} else {
sex = "f";
}
String date = new SimpleDateFormat("MMM dd yyyy", Locale.ENGLISH).format(person.getBirthDate());
System.out.println(name + " " + sex + " " + date);
}
}
break;
}
}
}