aspose file tools*
The moose likes Beginning Java and the fly likes Problem with Switch statements! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with Switch statements!" Watch "Problem with Switch statements!" New topic
Author

Problem with Switch statements!

Thijs Haitjema
Greenhorn

Joined: Sep 27, 2003
Posts: 1
Hello,
I have to make some applets for school with a dice. If the comuter makes me a number with math.random I want to show a picture of a dice with that number of dots on it. but I don't know how to work with a Switch statement. and where I have to put them in my applet?( under the init() stuff or where else?)
So I would appreciate it if you would help me.
Thijs Haitjema
haitjema@hotmail.com
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Hi,
Welcome to JavaRanch!
Sun's online Java Tutorial has a section on applets which would help you understand how applets are put together, and what the "init" and "start" methods are for.
As far as random numbers goes, to get a random number from 0 to 5, inclusive (six different possibilities), you could use the java.util.Random class:

You could then use this number as an index into an array of Image objects.


[Jess in Action][AskingGoodQuestions]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Here is a page from the JavaRanch Cattle Drive that may help you understand switch.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Switch statements!