0
package com.javarush.task.task17.task1710;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/*
CRUD
*/
public class Solution {
public static 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 IOException {
BufferedReader a = new BufferedReader(new InputStreamReader(System.in));
String b = a.readLine();
String[] c = b.split(" ");
if(c[0].equals("-c")){
if(c[2].equals("м")){
String[] birthdate = c[3].split("/");
Date bd = new Date(Integer.parseInt(birthdate[2])-1900, Integer.parseInt(birthdate[1])-1, Integer.parseInt(birthdate[0]));
allPeople.add(Person.createMale(c[1],bd));
System.out.println(allPeople.indexOf(allPeople.get(allPeople.size()-1)));
}
else if(c[2].equals("ж")){
String[] birthdate = c[3].split("/");
Date bd = new Date(Integer.parseInt(birthdate[2])-1900, Integer.parseInt(birthdate[1])-1, Integer.parseInt(birthdate[0]));
allPeople.add(Person.createFemale(c[1],bd));
System.out.println(allPeople.indexOf(allPeople.get(allPeople.size()-1)));
}
}
else if(c[0].equals("-u")){
if(c[3].equals("м")){
String[] birthdate = c[4].split("/");
Date bd = new Date(Integer.parseInt(birthdate[2])-1900, Integer.parseInt(birthdate[1])-1, Integer.parseInt(birthdate[0]));
allPeople.set(Integer.parseInt(c[1]), Person.createMale(c[2],bd));
}
else if(c[3].equals("ж")){
String[] birthdate = c[4].split("/");
Date bd = new Date(Integer.parseInt(birthdate[2])-1900, Integer.parseInt(birthdate[1])-1, Integer.parseInt(birthdate[0]));
allPeople.set(Integer.parseInt(c[1]),Person.createFemale(c[2],bd));
}
}
else if(c[0].equals("-d")){
allPeople.get(Integer.parseInt(c[1])).setName(null);
allPeople.get(Integer.parseInt(c[1])).setSex(null);
allPeople.get(Integer.parseInt(c[1])).setBirthDate(null);
}
else if(c[0].equals("-i")){
SimpleDateFormat smp = new SimpleDateFormat("dd-MMM-YYYY", Locale.ENGLISH);
if(allPeople.get(Integer.parseInt(c[1])).getSex()==Sex.MALE){
System.out.println(allPeople.get(Integer.parseInt(c[1])).getName() + " " + "м"+ " " + smp.format(allPeople.get(Integer.parseInt(c[1])).getBirthDate()));}
else if(allPeople.get(Integer.parseInt(c[1])).getSex()==Sex.FEMALE){
System.out.println(allPeople.get(Integer.parseInt(c[1])).getName() + " " + "ж"+ " " + smp.format(allPeople.get(Integer.parseInt(c[1])).getBirthDate()));}
else System.out.println(allPeople.get(Integer.parseInt(c[1])).getName() + " " +allPeople.get(Integer.parseInt(c[1])).getSex() + " " + smp.format(allPeople.get(Integer.parseInt(c[1])).getBirthDate()));
}
}
}