-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCity.java
More file actions
37 lines (29 loc) · 736 Bytes
/
Copy pathCity.java
File metadata and controls
37 lines (29 loc) · 736 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
public class City implements Comparable<City>{
private String name;
private float temperature;
public City(String name, float temperature) {
this.name = name;
this.temperature = temperature;
}
public String getName() {
return name;
}
public float getTemperature() {
return temperature;
}
public void setName(String name) {
this.name = name;
}
public void setTemperature(float temperature) {
this.temperature = temperature;
}
@Override
public int compareTo(City other) {
return name.compareTo(other.getName());
}
public String toString() {
String message = "The city " + name + " is measuring "
+ temperature + " F";
return message;
}
}