Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public class Paar<T> {
  2. private T wert1, wert2;
  3.  
  4. // Methoden
  5. public Paar(T w1, T w2)
  6. {
  7. this.wert1 = w1;
  8. this.wert2 = w2;
  9. }
  10.  
  11. public T getWert1()
  12. {
  13. return this.wert1;
  14. }
  15.  
  16. public T getWert2()
  17. {
  18. return this.wert2;
  19. }
  20.  
  21. public String toString()
  22. {
  23. return "(" + String.valueOf(this.wert1) + ", " + String.valueOf(this.wert2) + ")";
  24. }
  25.  
  26.  
  27. public boolean equals(Object o) {
  28. if(o instanceof Paar<?>) {
  29. Paar<?> p = (Paar<?>) o;
  30. // nun koennen Sie auf die Attribute des uebergebenen Objektes
  31. // ueber p zugreifen
  32. if(wert1.equals(p.wert1) && wert2.equals(p.wert2))
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement