2
Firro
7y

Hey, dunno where to Post it to get a Response as fast as possible but I think it's better to ask here than in stackoverflow. I need some help with Java and don't know what to even search for. The Problem is attached in a dumbed Down Version

Comments
  • 4
    Int rand = rand 0 or 1

    If rand is 1
    Init first
    Else
    Init other

    Why not this simplest way? Go for switch with cases if you have more classes.
  • 2
    @juzles Oh, haha yeah I guess i wanted to Make it complex. Thought of enums or Arrays to be able to generalize it. Thanks, really took me Back to the Basics where its at
  • 3
    Factory patter is your friend. Give an enum and return an instance! The enum is obtained randomly!
Add Comment