
public class Lista {
	private Pessoa pessoa;
	private Lista next;
	public static Egt egito = new Egt();
	public static Jpf jp = new Jpf();
	public static Brf br = new Brf();
	public static Pres p = new Pres();
	public static int ce, cj, cb, cp;
	public Lista() {
		this.pessoa = null;
		this.next = null;
	}
	public void insert(Pessoa pessoa) {
		if (this.pessoa == null) {
			this.pessoa = pessoa;
			this.next = new Lista();
		}else {
			this.next.insert(pessoa);
		}
	}
	public boolean check(Lista lst, String name) {
		if (lst.pessoa == null) {
			return false;
		}
		else if (lst.pessoa.getName().equals(name)) {
			return true;
		}else {
			return check(lst.next, name);
		}
	}
	public boolean viagem(Lista lst, String name, int ano) {
		if (lst.pessoa.getName().equals(name)) {
			String aux = lst.pessoa.getTmp();
			if ((ano >= -3100) && (ano <= -30)) {
				lst.pessoa.setTmp("Egito Antigo");
				lst.pessoa.setCnt(ce);
				ce++;
			}else if ((ano >= 794) && (ano <= 1185)) {
				lst.pessoa.setTmp("Japao Feudal");
				lst.pessoa.setCnt(cj);
				cj++;
			}else if (ano >= 2235) {
				lst.pessoa.setTmp("Brasil Futurista");
				lst.pessoa.setCnt(cb);
				cb++;
			}else if (ano == 2019) {
				lst.pessoa.setTmp("Presente");
				lst.pessoa.setCnt(cp);
				cp++;
			}else {
				System.out.println("Cuidado pra nao ficar preso no reino quantico, "+lst.pessoa.getName()+".");
				return true;
			}
			System.out.println(lst.pessoa.getName()+" foi de "+aux+" para "+lst.pessoa.getTmp()+".");
			return true;
		}else {
			return viagem(lst.next, name, ano);
		}
	}
	public boolean egpt(Lista lst) {
		if (lst.pessoa == null) {
			egito.print(egito);
			return true;
		}
		if (lst.pessoa.getTmp().equals("Egito Antigo")) {
			egito.insert(lst.pessoa);
		}
		return lst.next.egpt(lst.next);
	}
	public boolean jpf(Lista lst) {
		if (lst.pessoa == null) {
			jp.print(jp);
			return true;
		}
		if (lst.pessoa.getTmp().equals("Japao Feudal")) {
			jp.insert(lst.pessoa);
		}
		return lst.next.jpf(lst.next);
	}
	public boolean brf(Lista lst) {
		if (lst.pessoa == null) {
			br.print(br);
			return true;
		}
		if (lst.pessoa.getTmp().equals("Brasil Futurista")) {
			br.insert(lst.pessoa);
		}
		return lst.next.brf(lst.next);
	}
	public boolean pres(Lista lst) {
		if (lst.pessoa == null) {
			p.print(p);
			return true;
		}
		if (lst.pessoa.getTmp().equals("Brasil Futurista")) {
			p.insert(lst.pessoa);
		}
		return lst.next.pres(lst.next);
	}
}