[Logo]
Forums Register Login
Coin Flipping Program!
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.
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.
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
 

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,

Thanks, this was what i was looking for
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS


This thread has been viewed 6925 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 21, 2018 22:25:17.