-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathPets.java
More file actions
43 lines (26 loc) · 787 Bytes
/
Pets.java
File metadata and controls
43 lines (26 loc) · 787 Bytes
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
package io.zipcoder;
import java.util.Comparator;
public abstract class Pets implements Comparable<Pets> , Comparator<Pets>{
protected String name;
protected Pets(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public abstract String speak();
public int compareTo(Pets pet) {
int compare = this.getName().compareToIgnoreCase(pet.getName());
if(compare != 0) {
return compare;
} else {
compare = this.getClass().getSimpleName().compareToIgnoreCase(pet.getClass().getSimpleName());
return compare;
}
}
public int compare(Pets pet1, Pets pet2) {
}
}