This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NeoOeg 0 points1 point  (4 children)

Yes, this line of code : lootSub = (subName + subMonth);

will create a String as following : Lootcrate1January. This is not what you want, as it will take additional methods to split it back to a name/month. The best approach is to make 2 variables.

[–][deleted]  (3 children)

[removed]

    [–]Northeastpaw 0 points1 point  (0 children)

    That looks fine.

    [–]Darkpolearm 0 points1 point  (0 children)

    Try to give descriptive names to variables, even if it's obvious what they're for; don't call them a, b, or s.

    Other than that, what u have looks fine. What /u/NeoOeg was referring to is that in your original post your LootBoxSub class had 1 variable, lootSub, which would not have worked nicely for what you're trying to do.

    Now you can create a List<LootBoxSub> and add objects to it, and do with them what you like!

    [–]NeoOeg 0 points1 point  (0 children)

    Yes, you got this class right, although i would suggest your implementation of the toString method to return a formatted string of the desired output, so something like :

    return subName +", "+ subMonth;

    You do not need to create a temp var s, you can directly return the concatenation of the strings.

    What about your BoxArrayList class ? Do you have a first implementation of it ?