Joseph Posted May 29, 2014 Share Posted May 29, 2014 (edited) its an unfinished, but it still might be helpful to others. public class HerbData { public HerbData() {} public static enum Herb { //NONE(-1, -1, -1, -1, -1), GUAM(3, 249, 250, 199, 200), MARRENTILL(5, 251, 252, 201, 202), TARROMIN(11, 253, 254, 203, 204), HARRALANDER(20, 255, 256, 205, 206), RANARR(25, 257, 258, 207, 208), TOADFLAX(30, 2998, 2999, 3049, 3050), IRIT(40, 259, 260, 209, 210), AVANTOE(48, 261, 262, 211, 212), KWUARM(54, 263, 264, 213, 214), SNAPDRAGON(59, 3000, 3001, 3051, 3052), CADANTINE(65, 265, 266, 215, 216), LANTADYME(67, 2481, 2482, 2485, 2486), DWARFWEED(70, 267, 268, 217, 218), TORSTOL(75, 269, 270, 219, 220); private int level, cleanUnnoted, cleanNoted, grimyUnnoted, grimyNoted; private String unfinPotion; Herb(int level, int cleanUnnoted, int cleanNoted, int grimyUnnoted, int grimyNoted) { this.level = level; this.cleanUnnoted = cleanUnnoted; this.cleanNoted = cleanNoted; this.grimyUnnoted = grimyUnnoted; this.grimyNoted = grimyNoted; this.unfinPotion = super.name().toLowerCase() +" potion (unf)"; } @Override public String toString() { return super.name().charAt(0) + super.name().substring(1).toLowerCase() +", Level: " +level; } public int getIdLevel() { return this.level; } public int getCleanUnnoted() { return this.cleanUnnoted; } public int getGrimyUnnoted() { return this.grimyUnnoted; } public int getCleanNoted() { return this.cleanNoted; } public int getGrimyNoted() { return this.grimyNoted; } public String getUnfinPotion() { return this.unfinPotion; } } public static enum Secondary { EYE_OF_NEWT, UNICORN_HORN_DUST, LIMPWURT_ROOT, SWAMP_TAR, RED_SPIDERS1_EGGS, CHOCOLATE_DUST, WHITE_BERRIES, TOAD1S_LEGS, CRUSHED_GOAT1S_HORN, SNAPE_GRASS, MORT_MYRE_FUNGUS, KEBBIT_TEETH_DUST, //GROUND_GORAK_CLAW, This isnt the corrct name, figure out what it is, then change it BLUE_DRAGON_SCALE, WINE_OF_ZAMORAK, POTATO_CACTUS, JANGERBERRIES, CRUSHED_NEST, POISON_IVY_BERRIES, LAVA_DRAGON_SCALE; @Override public String toString() { return super.name().replace("_", " ").replace("1", "'").replace("2", "-").toLowerCase(); } } public static enum Potion { ATTACK_POTION(3, Herb.GUAM, Secondary.EYE_OF_NEWT), ANTIPOISON(5, Herb.MARRENTILL, Secondary.UNICORN_HORN_DUST), STRENGTH_POTION(12, Herb.TARROMIN, Secondary.LIMPWURT_ROOT), GUAM_TAR(19, Herb.GUAM, Secondary.SWAMP_TAR), STAT_RESTORE_POTION(22, Herb.HARRALANDER, Secondary.RED_SPIDERS1_EGGS), ENERGY_POTION(26, Herb.HARRALANDER, Secondary.CHOCOLATE_DUST), DEFENCE_POTION(30, Herb.RANARR, Secondary.WHITE_BERRIES), MARRENTIL_TAR(31, Herb.MARRENTILL, Secondary.SWAMP_TAR), AGILITY_POTION(34, Herb.TOADFLAX, Secondary.TOAD1S_LEGS), COMBAT_POSTION(36, Herb.HARRALANDER, Secondary.CRUSHED_GOAT1S_HORN), PRAYER_POTION(38, Herb.RANARR, Secondary.SNAPE_GRASS), TARROMIN_TAR(39, Herb.TARROMIN, Secondary.SWAMP_TAR), HARRALANDER_TAR(44, Herb.HARRALANDER, Secondary.SWAMP_TAR), SUPER_ATTACK_POTION(45, Herb.IRIT, Secondary.EYE_OF_NEWT), SUPER_ANTIPOISON(48, Herb.IRIT, Secondary.UNICORN_HORN_DUST), FISHING_POTION(50, Herb.AVANTOE, Secondary.SNAPE_GRASS), SUPER_ENERGY_POTION(52, Herb.AVANTOE, Secondary.MORT_MYRE_FUNGUS), HUNTING_POTION(53, Herb.AVANTOE, Secondary.KEBBIT_TEETH_DUST), SUPER_STRENGTH_POTION(55, Herb.KWUARM, Secondary.LIMPWURT_ROOT), WEAPON_POISON(60, Herb.KWUARM, Secondary.BLUE_DRAGON_SCALE), SUPER_RESTORE_POTION(63, Herb.SNAPDRAGON, Secondary.RED_SPIDERS1_EGGS), SUPER_DEFENCE_POTION(66, Herb.CADANTINE, Secondary.WHITE_BERRIES), ANTIFIRE_POTION(69, Herb.LANTADYME, Secondary.BLUE_DRAGON_SCALE), //CHECK NAME RANGING_POTION(72, Herb.DWARFWEED, Secondary.WINE_OF_ZAMORAK), MAGIC_POTION(76, Herb.LANTADYME, Secondary.POTATO_CACTUS), ZAMORAK_BREW(78, Herb.TORSTOL, Secondary.JANGERBERRIES), SARADOMIN_BREW(81, Herb.TOADFLAX, Secondary.CRUSHED_NEST), EXTENDED_ANTIFIRE_POTION(84, Potion.ANTIFIRE_POTION, Secondary.LAVA_DRAGON_SCALE); private int level; private Herb herb; private Secondary secondary; private Potion potion; Potion(int level, Herb herb, Secondary secondary) { this.level = level; this.herb = herb; this.potion = null; this.secondary = secondary; } Potion(int level, Potion potion, Secondary secondary) { this.level = level; this.herb = null; this.potion = potion; this.secondary = secondary; } @Override public String toString() { return super.name().charAt(0) + super.name().substring(1).replace("_", " ").toLowerCase() +", Level: " +level; } public int getLevel() { return this.level; } public Herb getHerb() { return this.herb; } public Potion getPotion() { return this.potion; } public Secondary getSecondary() { return this.secondary; } } } Edited May 30, 2014 by josedpay Link to comment Share on other sites More sharing options...
Swizzbeat Posted May 29, 2014 Share Posted May 29, 2014 (edited) There's no reason to have an empty default constructor, and your toString could be a lot cleaner and efficient: @Override public String toString() { final StringBuilder sb = new StringBuilder(super.toString()); return sb.charAt(0) + sb.substring(1).toLowerCase().replace("_", " "); } Edited May 30, 2014 by Swizzbeat Link to comment Share on other sites More sharing options...
Joseph Posted May 30, 2014 Author Share Posted May 30, 2014 (edited) There's no reason to have an empty default constructor, and your toString could be a lot cleaner: @Override public String toString() { final StringBuilder sb = new StringBuilder(super.toString()); return sb.charAt(0) + sb.substring(1).toLowerCase().replace("_", " "); } opp i didnt mean to leave those empty parameter. Also my toString() is pretty clean. The only reason why they are like that, its so it can be the actual name in rs. for example: Secondary.RED_SPIDERS1_EGGS.toString() will return Red spiders' eggs just like in runescape. exact name Edited May 30, 2014 by josedpay Link to comment Share on other sites More sharing options...
Swizzbeat Posted May 30, 2014 Share Posted May 30, 2014 opp i didnt mean to leave those empty parameter. Also my toString() is pretty clean. The only reason why they are like that, its so it can be the actual name in rs. for example: Secondary.RED_SPIDERS1_EGGS.toString() will return red spiders' eggs just like in runescape. exact name The code I posted returns the same exact String and is more efficient. You're calling the #name() method twice as well as creating additional String objects while mine only uses only a single StringBuilder. Strings are immutable, which means any operation on them creates an entirely new String instance (leaving the other to be garbage collected). 1 Link to comment Share on other sites More sharing options...
Joseph Posted May 30, 2014 Author Share Posted May 30, 2014 so your trying to say that its better to use StringBuilder then super.name() Link to comment Share on other sites More sharing options...
Swizzbeat Posted May 30, 2014 Share Posted May 30, 2014 (edited) so your trying to say that its better to use StringBuilder then super.name() Well they're not really comparable as they do completely separate things. I'm just saying it's more efficient to use a StringBuilder object when doing multiple operations on a String rather than modify it and litter the stack with unneeded variables. Also, why didn't you just make a String variable to store the name of the enum instead of calling the #name() method twice? Edited May 30, 2014 by Swizzbeat Link to comment Share on other sites More sharing options...
Joseph Posted May 30, 2014 Author Share Posted May 30, 2014 (edited) Well they're not really comparable as they do completely separate things. I'm just saying it's more efficient to use a StringBuilder object when doing multiple operations on a String rather than modify it itself. Also, why didn't you just make a String variable to store the name of the enum instead of calling the #name() method twice? its call laziness lol, ill update this in a little edit: Question why would you use, toString() in your string builder when your trying to modify toString(). @Swizzbeat Edited May 30, 2014 by josedpay Link to comment Share on other sites More sharing options...
Swizzbeat Posted May 30, 2014 Share Posted May 30, 2014 its call laziness lol, ill update this in a little edit: Question why would you use, toString() in your string builder when your trying to modify toString(). @Swizzbeat StringBuilder takes a String argument. Link to comment Share on other sites More sharing options...
TheScrub Posted May 30, 2014 Share Posted May 30, 2014 sorry to shit on your parade storing both the note and the unoted id's are a waste your return method should be like public int getCleanNoted() { return this.cleanUnnoted+1; } seems more efficient than writing all those digits in good work though! Link to comment Share on other sites More sharing options...
Joseph Posted May 31, 2014 Author Share Posted May 31, 2014 sorry to shit on your parade storing both the note and the unoted id's are a waste your return method should be like public int getCleanNoted() { return this.cleanUnnoted+1; }seems more efficient than writing all those digits in good work though! You could do that, but at the time I wrote I wanted to make sure I got all ids correct Link to comment Share on other sites More sharing options...