-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMamal.java
63 lines (50 loc) · 1.5 KB
/
Mamal.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.artyom.khvediouk.Model;
public class Mamal extends Animal {
private String specialAbility;
public Mamal(String name, int age, Color color, String specialAbility) {
super(name, age, color);
this.specialAbility = specialAbility;
}
@Override
public void eat() {
System.out.println(" I am mamal , I am eating");
}
@Override
public void sleep() {
System.out.println(" I am mamal , I am going to sleep");
}
void walk() {
System.out.println(" I am mamal , I am walking");
}
public String getSpecialAbility() {
return specialAbility;
}
public void setSpecialAbility(String specialAbility) {
this.specialAbility = specialAbility;
}
@Override
public String toString() {
return " I am mamal ,my name is: " + super.getName() + " my age is " + super.getAge() + "\n"
+ "my color is :" + super.getColor() + " my special ability is " + specialAbility;
}
@Override
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (o == this) {
return true;
}
if (o instanceof Mamal) {
Mamal other = (Mamal) o;
if (super.equals(other) && this.getSpecialAbility().equals(other.getSpecialAbility())) {
return true;
}
}
return false;
}
@Override
public Object clone() {
return super.clone();
}
}