/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

public class TaskEmployee {
    public static void main(String[] args) {
        DataBase dataBase = new DataBase();
        for (Employee em : dataBase.findByString("ge")) {
            System.out.println("FindByString \n" + em.toString());
        }
        dataBase.setDateNow("2015 1");
        for (Employee em : dataBase.findByYears(2)) {
            System.out.println("findByYears\n" + em.toString());
        }
    }
}
 
class Employee {
    private String lastName;
    private String firstName;
    private String midName;
    private String address;
    private String date;
 
    public Employee(String lastName, String firstName, String midName, String address, String date) {
        this.lastName = lastName;
        this.firstName = firstName;
        this.midName = midName;
        this.address = address;
        this.date = date;
    }
 
    public Employee(String lastName, String firstName, String address, String date) {
        this.lastName = lastName;
        this.firstName = firstName;
        this.address = address;
        this.date = date;
    }
 
    public String getLastName() {
        return lastName;
    }
 
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
 
    public String getFirstName() {
        return firstName;
    }
 
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
 
    public String getMidName() {
        return midName;
    }
 
    public void setMidName(String midName) {
        this.midName = midName;
    }
 
    public String getAddress() {
        return address;
    }
 
    public void setAddress(String address) {
        this.address = address;
    }
 
    public String getDate() {
        return date;
    }
 
    public void setDate(String date) {
        this.date = date;
    }
 
    public int getYear(String now) {
        int year = Integer.parseInt(now.split(" ")[0]);
        int month = Integer.parseInt(now.split(" ")[1]);
        String date = getDate();
        int y = Integer.parseInt(date.split(" ")[0]);
        int m = Integer.parseInt(date.split(" ")[1]);
        y = year - y;
        if (month < m) {
            y--;
        }
        return y;
    }
 
    @Override
    public String toString() {
        return "Employee : " +
                "lastName='" + lastName + '\'' +
                ", firstName='" + firstName + '\'' +
                ", midName='" + midName + '\'' +
                ", address='" + address + '\'' +
                ", date='" + date + '\'';
    }
}
 
class DataBase {
 
    private List<Employee> employeeList;
    private String dateNow;
 
    public DataBase() {
        this.employeeList = new ArrayList<Employee>();
        employeeList.add(new Employee("Vihrev", "Petr", "Petrovich", "Ivanovo", "2010 5"));
        employeeList.add(new Employee("Petrov", "Vasiliy", "Ivanovich", "Kazan", "2011 3"));
        employeeList.add(new Employee("Gareev", "Evgeniy", "Ufa", "2015 5"));
        employeeList.add(new Employee("Plotnikov", "Georgiy", "Omsk", "2012 1"));
        employeeList.add(new Employee("Grishakov", "Roman", "Mihaylovich", "Moscow", "2014 8"));
    }
 
    public String getDateNow() {
        return dateNow;
    }
 
    public void setDateNow(String dateNow) {
        this.dateNow = dateNow;
    }
 
    public List<Employee> getEmployeeList() {
        return employeeList;
    }
 
    public List<Employee> findByYears(int year) {
        List<Employee> res = new ArrayList<>();
        for (Employee emp : getEmployeeList()) {
            if (emp.getYear(getDateNow()) >= year) {
                res.add(emp);
            }
        }
        return res;
    }
 
    public List<Employee> findByString(String ex) {
        List<Employee> res = new ArrayList<>();
        String reg = ex.toLowerCase();
        for (Employee emp : getEmployeeList()) {
            String sum = (emp.getFirstName() + " " + emp.getLastName() + " " + emp.getMidName()).toLowerCase();
            if (sum.contains(reg)) {
                res.add(emp);
            }
        }
        return res;
    }
}