ความคิดเห็น (1)
  • เป็นที่นิยม
  • ใหม่
  • เก่า
คุณต้องลงชื่อเข้าใช้เพื่อแสดงความคิดเห็น
Mack
ระดับ , ,ระระ
14 December 2018, 22:15
How did you do task 1714 "Comparable" ? I have problem with method ComareTo().. @Override public synchronized int compareTo(Beach o) { float f = Float.compare(this.distance, o.distance); int i = Integer.compare(quality, o.quality); return (f==0 && i==0)? 0 : 1; } Validator: The Beach class's compareTo method should at least account for beach quality and distance. Be sure that x.compareTo(y) == -y.compareTo(x) Be sure that compareTo returns different values for different objects.