Jump to content

How can I store multiple areas in one array?


Cockiezi

Recommended Posts

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 sad.png

Someone plz enlighten me.

 

 

I think you have a misunderstanding of the concept of reuse. Enums are made exactly for things such as this.

  • Like 1
Link to comment
Share on other sites

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

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. happy.png

Gave me a fun idea.

 

Whats better about an enum compared to having a list of areas in a separate class?

Edited by Isolate
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...