Advertisement
Guest User

City

a guest
Sep 18th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. package ee.ttu.algoritmid.guessinggame;
  2.  
  3. public class City implements Comparable<City> {
  4.  
  5.     private String name;
  6.     private int population;
  7.  
  8.     public City(String name, int population) {
  9.         this.name = name;
  10.         this.population = population;
  11.     }
  12.  
  13.     public String getName() {
  14.         return this.name;
  15.     }
  16.  
  17.     public Integer getPopulation() {
  18.         return this.population;
  19.     }
  20.  
  21.     @Override
  22.     public int compareTo(City c) {
  23.  
  24.         return getPopulation().compareTo(c.getPopulation());
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement