Khaleesi Posted January 22, 2015 Share Posted January 22, 2015 we were never explained how to use it. he never say anything about banks. I use that enum above as an example. with an enum you can loop through the variables rather than having a nested if statement. True or make an array of areas Link to comment Share on other sites More sharing options...
Mysteryy Posted January 23, 2015 Share Posted January 23, 2015 Well i don't see the point in coding more than you have to... Sure this: public enum Location { //your pre-definding the value of whatever you need. AREA_ONE(new Area(3092, 3246, 3095, 3240)), AREA_TWO (new Area(3215, 9623, 3219, 9620)), AREA_WHATEVER_YOU WANT (new Area(3207, 3220, 3210, 3216)), ; //these are the private fields you pre-definded private Area area; //constructor add what values you need to pre-define private Location(Area area){ this.area = area; } //these are simple getter methods. //setter method arent allowed because the values are pre-fined so they are basically static. public Area getArea(){ return this.area; } } Looks great and all but why when Area AREA_ONE = new Area(3092, 3246, 3095, 3240); Area AREA_TWO = new Area(3215, 9623, 3219, 9620); Area AREA_WHATEVER_YOU_WANT = new Area(3207, 3220, 3210, 3216); Would do the same thing or even storing it it a lil nooby class like public class Areas { static Area AREA_ONE = new Area(3092, 3246, 3095, 3240); static Area AREA_TWO = new Area(3215, 9623, 3219, 9620); static Area AREA_WHATEVER_YOU_WANT = new Area(3207, 3220, 3210, 3216); } would do the same thing It might just be me being super lazy but i see no point in over complicating the situation Someone plz enlighten me. I think you have a misunderstanding of the concept of reuse. Enums are made exactly for things such as this. 1 Link to comment Share on other sites More sharing options...
Isolate Posted January 23, 2015 Share Posted January 23, 2015 I think you have a misunderstanding of the concept of reuse. Enums are made exactly for things such as this. Reuse in which way, more than one time in the same script or across multiple? Link to comment Share on other sites More sharing options...
Mysteryy Posted January 23, 2015 Share Posted January 23, 2015 Reuse in which way, more than one time in the same script or across multiple? Either way. If you make that enum one time, you can just call it from the enum each time you need that area. I keep all of my scripts in the same project, that way I can reuse every bit of my custom API code, web walker, etc. and I never have to rewrite code for any script twice if I have already written it. Then when I compile, I just compile the one script class that I want to submit. ^_^ Link to comment Share on other sites More sharing options...
Isolate Posted January 23, 2015 Share Posted January 23, 2015 (edited) Either way. If you make that enum one time, you can just call it from the enum each time you need that area. I keep all of my scripts in the same project, that way I can reuse every bit of my custom API code, web walker, etc. and I never have to rewrite code for any script twice if I have already written it. Then when I compile, I just compile the one script class that I want to submit. Gave me a fun idea. Whats better about an enum compared to having a list of areas in a separate class? Edited January 23, 2015 by Isolate Link to comment Share on other sites More sharing options...