Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. class Item implements Comparable<Item> {
  2.  
  3.     private String restOfString;
  4.     private int numCompounds;
  5.    
  6.     public Item(String str, int num)
  7.     {
  8.         restOfString = str;
  9.         numCompounds = num;
  10.     }
  11.  
  12.     public int compareTo(Item other) {
  13.         return this.numCompounds - other.numCompounds;
  14.     }
  15.    
  16.     public String toString()
  17.                        {
  18.         return new String(restOfString);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement