As you can guess I am new to the site - sorry if this is in the wrong place.
I am currently working on a project to develop a millionaire game - like the one seen on TV. The purpose is to learn more about Java. So far I have two old version i created a while back, which contain static questions. I am now wanting to redo the game and implement dymanic questions in to the game.
Below is part of the code for the randomQuestions class I have created:
The result I am after is somthing like below:
playingFor = "Question is worth £500"
question = "What is the captial of England"
optionOne = "London"
optionTow = "Berlin"
So far I have been using the subString method and had some luck. However, due to the strings in the array being different sizes, is there a better way of getting the values???
P.s. I am also wanting to in another version display the return values in a gui, how should I go about implementing this in the future?
Don’t try too many things at once. Get the command line version working first, then think about GUIs later. Do the whole thing bit by bit. If you write more than about 5 lines without running your code, you are liable to run into problems.
You ought to create a Question class, which you can give an array/list of possible answers to as a field. Then you can have a proper object-oriented application, rather than putting everything in the main method.
Joined: Dec 29, 2011
The program works, however, it is spliting the string up into sections for the different peices of information I am after
Could you provded a simple example of what you mean by a question class, as I am using randomQuestions as the question class.
Other classes in the program include: game, computer and player (for user input) and stop
Joined: Oct 13, 2005
You need a question class, which I wrote a few minutes ago and lost I shall start again
Now, you can do this sort of thing, which I have got by editing your code. Try that and see how much simpler the whole thing isWhat you were doing was putting all those Strings together, and the trying to take them apart. Why do you have to take them apart, when you can get away with not putting them together in the first place?
You can create the description String and the hash int in their respective methods if you prefer, but then they cannot be final.