samedi 31 janvier 2015

X:code Spacing error anywhere?

import UIKit


class ViewController: UIViewController {



@IBOutlet weak var QuestionLabel: UILabel!

@IBOutlet weak var Button1: UIButton!
@IBOutlet weak var Button2: UIButton!
@IBOutlet weak var Button3: UIButton!
@IBOutlet weak var Button4: UIButton!


var CorrectAnswer = String()

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

RandomQuestions()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}



func RandomQuestions(){

var RandomNumber = arc4random() % 4
RandomNumber += 1

switch(RandomNumber){
case 1:

QuestionLabel.text = "Who is the best soccer player in the world?"
Button1.setTitle("Messi", forState: UIControlState.Normal)
Button2.setTitle("Neymar", forState: UIControlState.Normal)
Button3.setTitle("Bale", forState: UIControlState.Normal)
Button4.setTitle("James", forState: UIControlState.Normal)
CorrectAnswer = "2"

break
case 2:
QuestionLabel.text = "How many goals is a hat trick?"
Button1.setTitle("2", forState: UIControlState.Normal)
Button2.setTitle("5", forState: UIControlState.Normal)
Button3.setTitle("3", forState: UIControlState.Normal)
Button4.setTitle("7", forState: UIControlState.Normal)
CorrectAnswer = "3"

break
case 3:
QuestionLabel.text = "What number is Neymar?"
Button1.setTitle("2", forState: UIControlState.Normal)
Button2.setTitle("5", forState: UIControlState.Normal)
Button3.setTitle("3", forState: UIControlState.Normal)
Button4.setTitle("11", forState: UIControlState.Normal)
CorrectAnswer = "4"
break

case 4:
QuestionLabel.text = "What number is messi?"
Button1.setTitle("2", forState: UIControlState.Normal)
Button2.setTitle("10", forState: UIControlState.Normal)
Button3.setTitle("3", forState: UIControlState.Normal)
Button4.setTitle("7", forState: UIControlState.Normal)
CorrectAnswer = "2"



break
default:

break
}

}

@IBAction func Button1Action(sender: AnyObject) {

if (CorrectAnswer == "1"){

NSLog("You Are Correct")
}
else{
NSLog("YOu Are Wrong")
}
}
@IBAction func Button2Action(sender: AnyObject) {
if (CorrectAnswer == "2"){

NSLog("You Are Correct")
}
else{
NSLog("YOu Are Wrong")
}
}
@IBAction func Button3Action(sender: AnyObject) {
if (CorrectAnswer == "3"){

NSLog("You Are Correct")
}
else{
NSLog("YOu Are Wrong")
}
}
@IBAction func Button4Action(sender: AnyObject) {
if (CorrectAnswer == "4"){

NSLog("You Are Correct")
}
else{
NSLog("You Are Correct")
}
}


Could anyone help me with this I'm need to coding and i need help with this. i have look for any extra brackets i put and i have seen none any help?




Aucun commentaire:

Enregistrer un commentaire