import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ArrayListUserDefinedObjectExample { // defining class
public static void main(String[] args) {
List<User> users = new ArrayList<>(); // setting arraylist
users.add(new User("David", "Pot" , 17, "male", "Armstrong Str. 24", "Griesheim, 57401", "Hessen")); // getting info of the given student
users.add(new User("John","Lok", 20, "male", "Madison Str. 76", "Darmstadt, 19050", "Hessen")); // getting info of the given student
users.add(new User("Daniel","Wild", 15, "male", "Gartner Str. 39", "Darmstadt, 34012", "Hessen")); // getting info of the given student
users.add(new User("Martin","Mill", 19, "male", "Willow Str. 12", "Offenbach, 45012", "Hessen")); // getting info of the given student
users.add(new User("Jake","Mill", 19, "male", "Willow Str. 12", "Offenbach, 45012", "Hessen")); // getting info of the given student
System.out.println("EKS administration");
System.out.println("----------------------------------");
users.remove(3); // removing object at the given index
users.add(2,new User("Logan","Paul", 18, "male", "Maximilian Str. 90", "Offenbach, 45012", "Hessen" )); // adding student at the given index
User u = new User();
System.out.println("Enter the name of the student that you are looking for: "); // user enters the student name
Scanner scanner = new Scanner(System.in);
u.setName(scanner.nextLine()); // the machine is searching all the names for the right one
for (User user : users){
if (u.getName().equalsIgnoreCase(user.getName())){
System.out.println("The name of the student is " + user.getName() +"\n" + user.getLastname()+ " and this student is " + user.getAge() +" years old" + "."+ "This student is a " + user.getSex() + "." + "\n" +"House adress of this student:" + user.getStreet()+ "\n"+ "City and postcode:"+ user.getPlace()+ "\n"+ "State:"+ user.getState());
} // user gets all the info for the student that he searched
else {
System.out.println("----------------------------------");
System.err.println("You gave a wrong name");
}
}
}
}