не принимает
package com.javarush.task.task17.task1714;
/*
Comparable
*/
public class Beach implements Comparable<Beach> {
private String name; //название
private float distance; //расстояние
private int quality; //качество
public synchronized int compareTo(Beach beach) {
int thisBeach = 0;
int argBeach = 0;
if (this.getDistance() - beach.getDistance() < 0) {
argBeach = argBeach + 1;
} else if (this.getDistance() - beach.getDistance() > 0) {
thisBeach = thisBeach + 1;
}
if (this.getQuality() - beach.getQuality() > 0) {
thisBeach = thisBeach + 1;
} else if (this.getQuality() - beach.getQuality() < 0) {
argBeach = argBeach +1;
}
return thisBeach - argBeach;
}
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;
}
public static void main(String[] args) {
Beach beachOne = new Beach("Лазурный", 2.5f, 4);
Beach beachTwo = new Beach("Золотой", 150.8f, 5);
System.out.println(beachOne.compareTo(beachTwo));
}
}