Jump to content

Difference between getGrandExchange and GrandExchange?


Psychotechno

Recommended Posts

Noob question incoming

When programming my bot to interact with the grand Exchange, I noticed that some snippets use the getGrandExchange() method in the MethodProvider, for example: 

getGrandExchange().isOpen()

And sometimes people don't use the MethodProvider, so they use GrandExchange class directly, like so:

if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.PENDING_BUY) {
   status = "Pending offer";
}else if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.FINISHED_BUY) {
   status = "Offer completed - Collecting";
}

What is the difference between the two? The same applies with Inventory class & getInventory(), Bank class & getBank() etc....  

I guess this question could be phrased more generally: What is the difference between using methodProvider get-functions or interacting with the classes directly? 

Link to comment
Share on other sites

Generally, you should always use getters/setters for variables contained in other classes, if one is provided as they may be doing more than just returning the variable. In example, calling getInventory() instead of just calling the variable could actually be verifying that it is returning the most up-to-date  Inventory state, instead of the one that is currently cached.

Edited by BravoTaco
  • Like 1
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...