aznishboy

Item

Jan 8th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.58 KB | None | 0 0
  1. http://pastebin.com/U9kMi5CU
  2. import chn.util.*;
  3. import apcslib.*;
  4. import java.util.*;
  5.  
  6. public class Item implements Comparable{
  7.     private int myId;
  8.     private int myInv;
  9.     public Item(int id, int inv){
  10.         myId = id;
  11.         myInv = inv;
  12.     }
  13.     public int getId(){
  14.         return myId;
  15.     }
  16.     public int getInv(){
  17.         return myInv;
  18.     }
  19.     public int compareTo(Object otherObject){
  20.         Item right = (Item)otherObject;
  21.         return (myId - right.getId());
  22.     }
  23.     public boolean equals(Object otherObject){
  24.         return compareTo(otherObject) == 0;
  25.     }
  26.     public String toString(){
  27.         return (myId + "    " + myInv);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment