что не так?
package com.javarush.task.task17.task1714;
/*
Comparable
*/
public class Beach implements Comparable<Beach>{
private String name; //название
private float distance; //расстояние
private int quality; //качество
public Beach(String name, float distance, int quality) {
this.name = name;
this.distance = distance;
this.quality = quality;
}
public synchronized String getName() {
return name;
}
public synchronized void setName(String name) {
this.name = name;
}
public synchronized float getDistance() {
return distance;
}
public synchronized void setDistance(float distance) {
this.distance = distance;
}
public synchronized int getQuality() {
return quality;
}
public synchronized void setQuality(int quality) {
this.quality = quality;
}
@Override
public synchronized int compareTo(Beach o) {
float a = this.distance + this.quality;
float b = o.distance + o.quality;
int c = (int) a - (int)b;
if (a > b) {
return c;
} else if (a < b) {
return c;
} else {
return 0;
}
}
public synchronized static void main(String[] args) {
Beach beach = new Beach("name1", 34, 46);
Beach beach2 = new Beach("name2", 3, 4);
System.out.println(beach.compareTo(beach2));
System.out.println(beach2.compareTo(beach));
}
}