Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gw2.tot;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.Comparator;
- import java.util.Iterator;
- import java.util.Map;
- import java.util.Scanner;
- import java.util.TreeMap;
- import org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument;
- public class ToTDrops
- {
- private TreeMap<String,Integer> dropMappings ;
- private int bagCount ;
- public ToTDrops()
- {
- dropMappings = new TreeMap<String,Integer>(new IgnoreCaseComparator()) ;
- setUp() ;
- }
- public void incrementTotal(String item, int increment) throws ItemNotFoundException
- {
- if(increment > 0) {
- if(dropMappings.containsKey(item) == true) {
- dropMappings.put(item,dropMappings.get(item) + increment) ;
- } else {
- throw new ItemNotFoundException("The item you entered is not a valid drop.") ;
- }
- } else {
- throw new IllegalArgumentException("Increment must be greater than 0") ;
- }
- }
- public void decrementTotal(String item, int decrement) throws ItemNotFoundException
- {
- if(decrement > 0) {
- if(dropMappings.containsKey(item) == true) {
- dropMappings.put(item,dropMappings.get(item) - decrement) ;
- } else {
- throw new ItemNotFoundException("The item you entered is not a valid drop.") ;
- }
- } else {
- throw new IllegalArgumentException("Decrement must be greater than 0") ;
- }
- }
- public void generateEntryList() throws Exception
- {
- OdfSpreadsheetDocument odt = OdfSpreadsheetDocument.loadDocument("ToTDrops.odt");
- Iterator<Map.Entry<String,Integer>> it = dropMappings.entrySet().iterator();
- int i = 1 ;
- while (it.hasNext() == true) {
- Map.Entry pairs = (Map.Entry)it.next();
- odt.getTableList().get(0).getCellByPosition("A" + i).setDisplayText((String) pairs.getKey()) ;
- odt.getTableList().get(0).getCellByPosition("B" + i).setDisplayText((pairs.getValue().toString())) ;
- it.remove(); // avoids a ConcurrentModificationException
- i++ ;
- }
- try {
- odt.save("ToTDrops.odt") ;
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- private void setUp()
- {
- dropMappings.put("Bowl of Candy Corn Custard",0) ;
- dropMappings.put("Glazed Peach Tart",0) ;
- dropMappings.put("Glazed Pear Tart",0) ;
- dropMappings.put("Piece of Candy Corn x1",0) ;
- dropMappings.put("Piece of Candy Corn Almond Brittle",0) ;
- dropMappings.put("Rotten Egg",0) ;
- dropMappings.put("Spicy Pumpkin Cookie",0) ;
- dropMappings.put("Strawberry Ghost",0) ;
- dropMappings.put("Toilet Paper",0) ;
- dropMappings.put("Chattering Skull x1",0) ;
- dropMappings.put("Nougat Center x1",0) ;
- dropMappings.put("Plastic Fang x1",0) ;
- dropMappings.put("Recipe: Candy Corn Custard",0) ;
- dropMappings.put("Recipe: Major Rune of the Mad King",0) ;
- dropMappings.put("Recipe: Major Sigil of the Night",0) ;
- dropMappings.put("Recipe: Superior Rune of the Mad King",0) ;
- dropMappings.put("Recipe: Superior Sigil of the Night",0) ;
- dropMappings.put("Recipe: Strawberry Ghost",0) ;
- dropMappings.put("Candy Corn Tonic",0) ;
- dropMappings.put("Concentrated Halloween Tonic",0) ;
- dropMappings.put("Endless Halloween Tonic",0) ;
- dropMappings.put("Halloween Tonic",0) ;
- dropMappings.put("Plastic Spider Tonic",0) ;
- }
- }
- class IgnoreCaseComparator implements Comparator<String>
- {
- public int compare(String s1, String s2)
- {
- return s1.compareToIgnoreCase(s2) ;
- }
- }
- class ItemNotFoundException extends Exception
- {
- public ItemNotFoundException()
- {
- super() ;
- }
- public ItemNotFoundException(String message)
- {
- super(message) ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment