fork download
  1. class Main {
  2. public static void main(String[] args) {
  3. Olho[] ol = new Olho[2];
  4. ol[0] = new Olho("Castanho", true);
  5. ol[1] = new Olho("Azul", false);
  6. ol[0].verificar();
  7. }
  8. }
  9.  
  10. class Olho {
  11. private String cor;
  12. private boolean funciona;
  13. public String getCor() {
  14. return cor;
  15. }
  16. public void setCor(String cor) {
  17. this.cor = cor;
  18. }
  19. public Boolean getFunciona() {
  20. return funciona;
  21. }
  22. public void setFunciona(Boolean funciona) {
  23. this.funciona = funciona;
  24. }
  25. public Olho(String cor, Boolean funciona) {
  26. this.cor = cor;
  27. this.funciona = funciona;
  28. }
  29. public void verificar() {
  30. System.out.println("A cor do olho é: " + getCor());
  31. System.out.println("O olho funciona ? " + getFunciona());
  32. }
  33. }
  34.  
  35. //https://pt.stackoverflow.com/q/433966/101
Success #stdin #stdout 0.09s 35956KB
stdin
Standard input is empty
stdout
A cor do olho é: Castanho
O olho funciona ? true