Jump to content

Need some help with my deposit code


atoo

Recommended Posts

  if (this.bank.isOpen()) {
                    this.bank.depositAllExcept("Bronze axe", "Iron axe", "Steel axe", "Black axe", "Mithril axe", "Adamant axe", "Rune axe", "Dragon axe");
                    

Havent tested it so not sure if it woks, but it should :) 

 

I wrote that too, but i just thought if we include "axe" it wouldnt deposit it.

Thanks though :)

Link to comment
Share on other sites

Strange if it worked before and suddenly stops working. Also not too important in this situation but I think using .contains() could be bad practice if you were dealing with strings that used other words with the sequence "axe" but were not axes. Again there's no case in this situation but if you were dealing with axel logs, .endsWith() would be better in this case since we know our axes  always ends with "axe"

 

 

Edited by Hayase
  • Like 1
Link to comment
Share on other sites

best thing to do is make a constant that lists your axe names.

public static final String AXES = ("Bronze axe", "Iron axe", "Steel axe", "Black axe", "Mithril axe", "Adamant axe", "Rune axe", "Dragon axe");

if (this.bank.isOpen()) {
                    this.bank.depositAllExcept(AXES);

This will always call the list of axes (which i doubt will ever change) this is a helpful technique and makes the code much more readable and modular.

Edited by DocMatson
  • Like 1
Link to comment
Share on other sites

best thing to do is make a constant that lists your axe names.

public static final String AXES = ("Bronze axe", "Iron axe", "Steel axe", "Black axe", "Mithril axe", "Adamant axe", "Rune axe", "Dragon axe");

if (this.bank.isOpen()) {
                    this.bank.depositAllExcept(AXES);

This will always call the list of axes (which i doubt will ever change) this is a helpful technique and makes the code much more readable and modular.

Thanks mate :)

I always code messy lol, this will help a bit.

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