• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with editing variables.

 
raul vargas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I'm trying to make an applet that will display 3 images on one applet but with each instance being a random order of the images.

I'm having trouble determining how to edit the variables so that the switch will work effectively

Here are both parts of my code:



Second part:
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

We would need some more details, please. For a start: what is happening, and what did you expect to happen?
 
raul vargas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thank you!

I apologize for not clarifying

I'm trying to make these 3 dukes appear in a different order each time I run the applet but I can't make that happen at the moment.

I'm able to load all of them onto one applet but I can't get them to become random each instance.
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is happening? Have you put any print statements where you are choosing the different images? How do you know whether they are being loaded? How do you know whether the switch is being executed?

You have some repeated code; there are three places where you set the String to my nose feels funny. That ought to be pulled out as a method of its own, possibly setNoseColour(). That method can have private access. Or, you ought to give the class a constructor, where you set up the nose colour, and possibly the message. Do you ever change nose colour at all?
 
raul vargas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I know the switch is working because when I would run the applet, the first duke didn't say "give me something to do" but " I'm a hand-standing Duke". The images wouldn't change but the string of text would.

The other methods work fine and do load a blue nose with a string of text reading "my nose feels funny" or "what's up with the blue nose"

I just wanna change the order of the dukes each time I run the applet
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not put the three Dukes into a List, shuffle the List and then retrieve them in the new order.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic