PAZ1c
paz1c
Metóda equals()
•Riešenie: inžiniersky prístup: použitím IDE (Eclipse) a jeho nástroja na vygenerovanie metódy.
• public boolean equals(Object obj) {
• if (this == obj) return true;
• if (obj == null) return false;
• if (getClass() != obj.getClass()) return false;
• final Pes other = (Pes) obj;
• if (rasa == null) {
• if (other.rasa != null)
• return false;
• } else if (!rasa.equals(other.rasa))
• return false;
• if (vek != other.vek)
• return false;
• return true;
• }