I’m making this word game and when you submit a word I want that word to be checked if I have it in my ‘database’ I’ve setup a couple of words for example
word1: banana
word2: apple
word3: pineapple
word4: lemon
now I can do this by the code:
If (submitword isequalto banana){
//submitword
}
else if (submitword isequalto apple){
//submitword
}
else{
//give warning
}
the problem is that I got thousands of words and the ‘submitword’ action is hundreds of lines long so that would make my code way to long.
anyone knows an easier way to do this?
This depends on what kind of ‘database’ you are using. E.g. if you are using an external API (as many current word app do) it can decide for you if it is correct or not. Then you could use MySQL or any other type of SQL server and make some intelligent questions using SQL.
I get the idea that you need to write down what you want to do first, then investigate the best way of doing it, and then start implementing code. Design first principle!