import java.util.*; public class Main { public static void main(String[] args){ Scanner in = new Scanner(System.in); ArrayList<String[]> people = new ArrayList<String[]>(); while(in.hasNextLine()) { String message = in.nextLine(); if(message.equals("quit")) { break; } String[] type = message.split(" "); if(type[0].equals("add")) { String all=type[1]+" "+type[2]+" "+type[3]+"-"+type[4]+"-"+type[5]; String[] s =new String[3]; s[0]=type[1]; s[1]=type[2]; s[2]=all; people.add(s); }else if(type[0].equals("name")) { for(String[] s : people) { if(s[0].equals(type[1])) { System.out.println(s[2]); } } }else if(type[0].equals("sex")) { for(String[] s : people) { if(s[1].equals(type[1])) { System.out.println(s[2]); } } } } } } |
Double click to view unformatted code.