Guest User

Untitled

a guest
Jun 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. package labp2.lab11;
  2.  
  3. import java.util.Calendar;
  4.  
  5. public class Amigo {
  6.  
  7. private String nome;
  8. private Calendar aniversario;
  9.  
  10. public Amigo(String nome, Calendar aniversario) {
  11. if ((nome == null) || (aniversario == null)){
  12. throw new IllegalArgumentException("Estes campos nao podem ser vazio.");
  13. }
  14. if(nome.equals("")){
  15. throw new IllegalArgumentException("Nome nao pode ser vazio");
  16. }
  17. this.nome = nome;
  18. this.aniversario = aniversario;
  19. }
  20.  
  21. public String getNome(){
  22. return nome;
  23. }
  24.  
  25. public boolean equals(Object obj){
  26. if (!(obj instanceof Amigo)) {
  27. return false;
  28. }
  29. Amigo amg= (Amigo) obj;
  30. return amg.getNome();
  31. }
  32.  
  33. public Calendar getAniversario(){
  34. return aniversario;
  35. }
  36.  
  37.  
  38.  
  39. public void setAniversario(Calendar data){
  40. this.aniversario = aniversario;
  41. }
  42.  
  43. public void setNome(String novoNome){
  44. this.nome = nome;
  45. }
  46. }
Add Comment
Please, Sign In to add comment