有人能提供一下解决方法吗,我有点不太理解题目到底想让我做什么
package zh.codegym.task.task17.task1710;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/*
CRUD
*/
public class Solution {
public static List<Person> allPeople = new ArrayList<>();
public static BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
static {
allPeople.add(Person.createMale("唐纳德·坎普", new Date())); // id=0
allPeople.add(Person.createMale("拉里·盖茨", new Date())); // id=1
}
public static void main(String[] args) {
// 在这里开始
try {
String input="-c";
switch (input) {
case "-c":
allPeople.add(Person.createFemale("亚索", new Date()));
System.out.println(2);
break;
case "-u": {
System.out.println("输入指定人员的ID");
int num = Integer.parseInt(reader.readLine());
if (num > allPeople.size()) {
System.out.println("没有此人员");
return;
}
allPeople.get(num).setName("zhuxiaoming");
allPeople.get(num).setSex(Sex.MALE);
allPeople.get(num).setBirthDate(new Date());
break;
}
case "-d": {
System.out.println("输入指定人员的ID");
int num = Integer.parseInt(reader.readLine());
if (num > allPeople.size()) {
System.out.println("没有此人员");
return;
}
allPeople.get(num).setName(null);
allPeople.get(num).setSex(null);
allPeople.get(num).setBirthDate(null);
break;
}
case "-i": {
System.out.println("输入指定人员的ID");
int num = Integer.parseInt(reader.readLine());
if (num > allPeople.size()) {
System.out.println("没有此人员");
return;
}
String name = allPeople.get(num).getName();
String sex = allPeople.get(num).getSex().equals(Sex.MALE) ? "m" : "f";
Date birthday = allPeople.get(num).getBirthDate();
System.out.println(name + " " + sex + " " + birthday.getMonth() + " " + birthday.getDay() + " " + birthday.getYear());
break;
}
}
} catch (IOException ignored) {
}
}
}