Hi guys Im having trouble figuring out whats wrong. In the following function, when the category is Subtraction and the level Hard it skips past the function and goes to the division part. All my wording i believe is correct but I think something is wrong with my brackets. Spent over an hour trying to find it. Still can't. And btw, all the other categories and levels work, even in subtraction. The only false one is hard subtraction and I can't find what's wrong with my brackets.
Code:
func generate(){
if category == "Multiplication"{
if level == "Easy"{
part1 = Int(arc4random_uniform(UInt32(4)))
part2 = Int(arc4random_uniform(UInt32(4)))
questionsLbl.text = "\(part1) x \(part2)?"
answer = part1 * part2
createExtraAnswers()
}
if level == "Medium"{
part1 = Int(arc4random_uniform(UInt32(10)))
part2 = Int(arc4random_uniform(UInt32(10)))
questionsLbl.text = "\(part1) x \(part2)?"
answer = part1 * part2
createExtraAnswers()
}
if level == "Hard"{
part1 = Int(arc4random_uniform(UInt32(14)))
part2 = Int(arc4random_uniform(UInt32(14)))
questionsLbl.text = "\(part1) x \(part2)?"
answer = part1 * part2
createExtraAnswers()
}
}else{
if category == "Addition"{
if level == "Easy"{
part1 = Int(arc4random_uniform(UInt32(6)))
part2 = Int(arc4random_uniform(UInt32(6)))
questionsLbl.text = "\(part1) + \(part2)?"
answer = part1 + part2
createExtraAnswers()
}
if level == "Medium"{
part1 = Int(arc4random_uniform(UInt32(20)))
part2 = Int(arc4random_uniform(UInt32(20)))
questionsLbl.text = "\(part1) + \(part2)?"
answer = part1 + part2
createExtraAnswers()
}
if level == "Hard"{
part1 = Int(arc4random_uniform(UInt32(100)))
part2 = Int(arc4random_uniform(UInt32(100)))
questionsLbl.text = "\(part1) + \(part2)?"
answer = part1 + part2
createExtraAnswers()
}
}else{
if category == "Subtraction"{
if level == "Easy"{
part1 = Int(arc4random_uniform(UInt32(10)))
part2 = Int(arc4random_uniform(UInt32(10)))
questionsLbl.text = "\(part1) - \(part2)?"
answer = part1 - part2
if answer <= -1{
generate()
}
createExtraAnswers()
}
if level == "Medium"{
part1 = Int(arc4random_uniform(UInt32(25)))
part2 = Int(arc4random_uniform(UInt32(25)))
questionsLbl.text = "\(part1) - \(part2)?"
answer = part1 - part2
if answer <= -1{
generate()
}
createExtraAnswers()
}
if level == "Hard"{
part1 = Int(arc4random_uniform(UInt32(100)))
part2 = Int(arc4random_uniform(UInt32(100)))
questionsLbl.text = "\(part1) - \(part2)?"
answer = part1 - part2
createExtraAnswers()
}
}else{
if category == "Division"{
if level == "Easy"{
part1 = Int(arc4random_uniform(UInt32(37)))
part2 = Int(arc4random_uniform(UInt32(37)))
questionsLbl.text = "\(part1) / \(part2)?"
answerDub = Double(Double(part1) / Double(part2))
if (answerDub % 1 == 0) {
print("whole number confirmed")
print(answerDub)
answer = Int(answerDub)
print(answer)
createExtraAnswers()
} else {
generate()
}
}
}
if level == "Medium"{
part1 = Int(arc4random_uniform(UInt32(80)))
part2 = Int(arc4random_uniform(UInt32(80)))
questionsLbl.text = "\(part1) / \(part2)?"
answerDub = Double(Double(part1) / Double(part2))
if (answerDub % 1 == 0) {
print("whole number confirmed")
print(answerDub)
answer = Int(answerDub)
print(answer)
createExtraAnswers()
} else {
generate()
}
}
}
if level == "Hard"{
part1 = Int(arc4random_uniform(UInt32(140)))
part2 = Int(arc4random_uniform(UInt32(140)))
questionsLbl.text = "\(part1) / \(part2)?"
answerDub = Double(Double(part1) / Double(part2))
if (answerDub % 1 == 0) {
print("whole number confirmed")
print(answerDub)
answer = Int(answerDub)
print(answer)
createExtraAnswers()
} else {
generate()
}
}
}
}
}