Advertisement
Guest User

Untitled

a guest
May 25th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. package il.ac.tau.cs.sw1.ex8.wordsRank;
  2.  
  3. import java.util.Comparator;
  4.  
  5. import il.ac.tau.cs.sw1.ex8.wordsRank.RankedWord.rankType;
  6.  
  7. /**************************************
  8.  * Add your code to this class !!! *
  9.  **************************************/
  10.  
  11. class RankedWordComparator implements Comparator<RankedWord> {
  12.  
  13.     private rankType type;
  14.  
  15.     public RankedWordComparator(rankType cType) {
  16.         this.type = cType;
  17.     }
  18.  
  19.     @Override
  20.     public int compare(RankedWord o1, RankedWord o2) { 
  21.  
  22.         return o1.getRankByType(type) - o2.getRankByType(type);
  23.  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement