Skip to content

Instantly share code, notes, and snippets.

@joffilyfe
Created December 2, 2015 17:05
Show Gist options
  • Save joffilyfe/84b61d76dc5dde0a352e to your computer and use it in GitHub Desktop.
Save joffilyfe/84b61d76dc5dde0a352e to your computer and use it in GitHub Desktop.
public class Pessoa {
String nome;
Pessoa amigo = null;
public Pessoa(String x) {
this.nome = x;
}
public void setAmigo(Pessoa amigo) {
this.amigo = amigo;
}
public String getNome() {
return this.nome;
}
public String getAmigo() {
return this.amigo.getNome();
}
public String toString() {
if (this.amigo == this) {
return "É amigo dele mesmo..";
} else if (this.amigo == null) {
return "Não tem amigo";
}
return ("Meu nome é: " + this.nome + " e meu amigo se chama: " + this.amigo.getNome());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment