aspose file tools*
The moose likes Beginning Java and the fly likes Need help with editing variables. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help with editing variables." Watch "Need help with editing variables." New topic
Author

Need help with editing variables.

raul vargas
Greenhorn

Joined: Mar 15, 2012
Posts: 14


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

Joined: Oct 13, 2005
Posts: 39773
    
  28
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

Joined: Mar 15, 2012
Posts: 14

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

Joined: Oct 13, 2005
Posts: 39773
    
  28
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

Joined: Mar 15, 2012
Posts: 14

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

Joined: Oct 13, 2005
Posts: 39773
    
  28
Why not put the three Dukes into a List, shuffle the List and then retrieve them in the new order.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help with editing variables.