Created
December 2, 2015 17:05
-
-
Save joffilyfe/84b61d76dc5dde0a352e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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