• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help with editing variables.

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic