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

Coin Flipping Program!

Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 172
I have designed a coin Flipping program as follows:


But i want to design it using Enums but i am not getting exactly how to do it. This is my start


Please guide me if we can shuffle the enum values only and get the result to be the enum fields.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Have a look through the Enum class. Also the Java™ Language Specification section. You will see a values() method; you might be able to use that to get the individual objects from their number.
Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 172
First i have one more question, is it possible to define a shuffle method taking only the enum fields into account and shuffling and returning them
Embla Tingeling
Ranch Hand

Joined: Oct 22, 2009
Posts: 237
Jacob Sonia wrote:First i have one more question, is it possible to define a shuffle method taking only the enum fields into account and shuffling and returning them


I don't quite understand what you want to achieve but it's not hard at all to enhance an enum with a method that returns the enum constants at random,

Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 172
Thanks, this was what i was looking for
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Coin Flipping Program!
 
Similar Threads
purse
Enum
Wanting to ask user to keep "inputting" at the command prompt until a condition is reached
Please help me with the logic of the code!
unexpected output