I don't understand why this won't verify.
package com.codegym.task.task17.task1710;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/*
CRUD
*/
public class Solution {
public static 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) {
// Start here
String request;
int id;
String name;
String sex;
Date bd;
/* Sample Data
crudHandler("c","Joe Shmoe","m",new Date(06, 10, 1980));
crudHandler("i",0);
crudHandler("i",1);
crudHandler("i",2);
System.out.println();
crudHandler("d",2);
crudHandler("u",0,"jim Barnes","m",new Date(10,20,1976));
crudHandler("i",0);
crudHandler("i",1);
*/
}
public static void crudHandler(String request, String name, String sex, Date bd) {
//-c (adds a person with the specified arguments to the end of allPeople; displays the id on the screen)
if (sex.equals("m")) {
allPeople.add(Person.createMale(name, bd));
System.out.println((allPeople.size() + 1));
} else { // female
allPeople.add(Person.createFemale(name, bd));
System.out.println((allPeople.size() + 1));
}
}
public static void crudHandler(String request, int id, String name, String sex, Date bd){
//-u (updates the data of the person with the specified id)
if ( sex.equals("m")){
allPeople.set(id, (Person.createMale(name, bd)));
} else { //Female
allPeople.set(id, (Person.createFemale(name, bd)));
}
}
public static void crudHandler(String request, int id) {
if (request.equals("d")) { //-d replaces all of its data with null)
allPeople.get(id).setBirthDate(null);
allPeople.get(id).setName("");
allPeople.get(id).setSex(null);
} else { //-i (displays information about the person with the specified id:
// name sex (m/f) bd (format Apr 15 1990))
String pattern = "dd MM yyyy";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
String date = simpleDateFormat.format(allPeople.get(id).getBirthDate());
System.out.println(allPeople.get(id).getName() +" " +allPeople.get(id).getSex() +" " +date);
}
}
}