@Override
public synchronized int compareTo(Beach o) {
if(this == o || !(o instanceof Beach)) return 0;
Beach beach = (Beach) o;
return (int) (this.quality*this.distance - beach.quality* beach.distance);
}
重写的方法保证传入的对象的值比this小就返回正数就行了
正在讨论
评论 (1)
- 受欢迎
- 新
- 旧
你必须先登录才能发表评论
Guadalupe Gagnon
1 四月 2021, 13:33
The help section is for asking for help when stuck on a task.... not for posting your solution.....
0