Jump to content

Shortening stuff


Zodiac Dev

Recommended Posts

How would I make this into like a smaller thing, I have like 13 of these and it's getting a little long...

 

ab06769fa02523c9fde59e28fe719c74.png

if (comboBox1.getSelectedItem().toString().equals("Varrock-East | Logs")) {
                c.BANK_AREA_SELECTED = c.BANK_AREA_VEAST;
                c.TREE_AREA_SELECTED = c.TREE_AREA_VEAST;
                c.selectedTree = c.TREE;
                c.SELECTED_PRICE = p.getSellingPrice(c.Logs);
                c.Area = 1;
Link to comment
Share on other sites

Just make an enum and 1 void of loading the selected value


enum kinda example thing:

public enum Locations {
    VARROCK_EAST_NORMAL(new Area(0,0,0,0,), new Area(1,1,1,1), "Tree", "Logs");
    
    private Area bankArea;
    private Area treeArea;
    private String treeType;
    private String logs;


    Locations(Area bankArea,Area treeArea, String treeType, String logs){
     this.bankArea = bankArea;
        this.treeArea = treeArea;
        this.treeType = treeType;
    }
    
    public void load(){
        Global.BAKN_AREA_SELECTED = this.bankArea;
        Global.TREE_AREA_SELECTED = this.treeArea;
        Global.selectedTree = this.treeType;
        Global.SELECTED_PRICE = p.getSellingPrice(c.logs);
    }
}

 

then populate  a combo box with the values of the array in a way that suits you.
then you can do something like

(Locations) comoBox1.getSelectedItem().load();
Edited by Isolate
  • Like 1
Link to comment
Share on other sites

you should use an enum for accessing similar datas of different types. The enum allows us to pre-define data. Then we create getter methods to help us grab the type of data we need. All you need to do is return the select enum variable. With that variable you can grab whatever data you need

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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