I originally asked the question "how to make quiz app that has no right answer" and I've since learned that wasn't the correct approach. What I was trying to do was make a quiz, that depending on the answers you chose, suggested a certain artist to listen to. I was awarding all of the buttons a different amount of points, so that if you scored in a certain range, you'd be suggested a certain artist. It then clicked in my head that if I used a measurement other than one score, I could make the points easier to calculate. So I gave each artist their own category, and depending on the button you pressed, that category would be given a point.
For example
else if quuis > 3 { let alert = UIAlertController(title: "Check Out Quis Christ", message: "Quis Christ has a style of hip hip reminiscent of the golden age of lyricism and hard beats. Quis makes every line count with hard rhymes that any hip hop purist can enjoy", preferredStyle: .alert)
let restartAction = UIAlertAction(title: "restart", style: .default
, handler: { UIAlertAction in self.startOver()})
alert.addAction(restartAction)
present(alert, animated: true, completion: nil)
startButton.isHidden = false
}else if mojoI > 3 { let alert = UIAlertController(title: "Check Out Mojofree", message: "MoJo Free has a trap soul sound that feeds your curiosity if SZA and Erykah Badu came together and fused. She has raw lyricism and smooth voice that makes for a great listening experience ", preferredStyle: .alert)
let restartAction = UIAlertAction(title: "restart", style: .default
, handler: { UIAlertAction in self.startOver()})
alert.addAction(restartAction)
present(alert, animated: true, completion: nil)
startButton.isHidden = false
}else if billyI > 3 { let alert = UIAlertController(title: "Check Out Billypalmtrees", message: "Billypalmtrees has a rap style that can be compared to the great lupe fiasco with witty wordplay and infectious flow. He also is a hybrid artist who can also sing with smooth voice that you can sit back and enjoy", preferredStyle: .alert)
let restartAction = UIAlertAction(title: "restart", style: .default
, handler: { UIAlertAction in self.startOver()})
alert.addAction(restartAction)
present(alert, animated: true, completion: nil)
startButton.isHidden = false
}else if rebelI > 3 { let alert = UIAlertController(title: "Check Out Rebel Kuzco", message: "Rebel Kuzco has a new age rap style that keeps your nodding your head and singing along to any hit that plays from him. With catchy hooks complimented by high energy rhymes makes for a great listening experience.", preferredStyle: .alert)
let restartAction = UIAlertAction(title: "restart", style: .default
, handler: { UIAlertAction in self.startOver()})
alert.addAction(restartAction)
present(alert, animated: true, completion: nil)
startButton.isHidden = false
}
the problem Im running into though is that there are only 10 questions, and I have it set that if the score is greater 3, suggest that artists, but with only 10 questions, theres room for the scores to be close enough that the results may end up being multiple scores with more than 3 points. I know I could raise it to a higher threshold, but what id like to do is figure out how to write it so that it picks the one that scored the highest, not just the one that scored more than a certain number!
How would I write that out? in plain english, not code, what I have in my head is something that goes along the lines of
"if this score is greater than this, and this, and this, and this, then show this alert."
To get you started:
`
class Question {
let questionText = ""
let answer = 0
}
`
Then in your ViewController hook the buttons up to an IB Action. Give each button a different tag. Also make a question in IB Action:
let newQuestion = Question()
if sender.tag == 1 {
//User picked answer 1
newQuestion.answer = 1
}
Then do else if for 2,3,4
That should have gotten you going in the right direction