title: Switch for rock-paper-scissors
body: <p>I'm trying to make a simple rock-paper-scissors game. To do it I used a switch statement but for some reason it doesn't work properly.</p>
  
  <p>This is the structure I thought of to make this little game:</p>
  
  <p>There are three buttons for Rock,Scissors,Paper, and you have to choose one.
  There is a Label that tells what the opponent (computer) chose, and I named it opponentLabel.
  There is a Label that tells what the result is ("you won" for example) and I named it resultLabel</p>
  
  <p>and it works like this (this just the way it's structured):</p>
  
  <pre><code>var a = Int()
  if the player chooses Rock ---&gt; a = 0
  if the player chooses Paper ---&gt; a = 1
  if the player chooses Scissors ---&gt; a = 2
  
  For the opponent (computer, not a person) there is a randomNumber which
  could be 0,1,2, and same here, if 0-&gt;opponent chose rock, if 
  1-&gt;opponent chose paper, if 2-&gt; opponent chose scissors 
  </code></pre>
  
  <p>and then I wrote a switch statement that puts it all together.
  The problem is that for some reason, when I run the app, if I choose rock everything works fine, but when I choose paper or scissors the results are wrong. </p>
  
  <p>For example if I choose Paper (a = 1) and the opponent has paper (which means that the random number happened to be randomNumber = 1), the resultLabel is not "DRAW" as it would be supposed to be, but it is "You Lost": paper and scissors don't work !! What am I doing wrong? 
  Here is the full code:</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
  
  @IBOutlet weak var opponentLabel: UILabel!
  @IBOutlet weak var resultLabel: UILabel!
  @IBOutlet weak var rockButton: UIButton!
  @IBOutlet weak var paperButton: UIButton!
  @IBOutlet weak var scissorsButton: UIButton!
  
  
  
  
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  
      Hide()
  
  
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  
  
  func Hide() {
      opponentLabel.hidden = true
      resultLabel.hidden = true
  }
  
  func unHide() {
      opponentLabel.hidden = false
      resultLabel.hidden = false
  }
  
  
  var a = Int()
  
  var randomNumber = Int()
  
  func randomChoice() {
  
      randomNumber = Int(arc4random() % 3)
      NSLog("randomNumber%ld", randomNumber)
  
  
  
  }
  
  
  
  func gameOn() {
  
      switch(randomNumber) { 
  
      case 0:
          opponentLabel.text = "The opponent chose : ROCK"
          if a == 0 {
              resultLabel.text = "DRAW"
          } else {
              if a == 1 {
                  resultLabel.text = "YOU WON!"
              }
              if a == 2 {
                  resultLabel.text = "YOU LOST!"
                  }
          }
          unHide()
          break
  
      case 1:
          opponentLabel.text = "The opponent chose: PAPER"
          if a == 0 {
              resultLabel.text = "YOU LOST!"
          } else {
              if a == 1 {
                  resultLabel.text = "DRAW"
              }
              if a == 2 {
                  resultLabel.text = "YOU WON!"
              }
          }
          unHide()
          break
  
      case 2:
          opponentLabel.text = "The opponent chose: SCISSORS"
          if a == 0 {
              resultLabel.text = "YOU WON!"
          } else {
              if a == 1 {
                  resultLabel.text = "YOU LOST!"
              }
              if a == 2 {
                  resultLabel.text = "DRAW"
              }
          }
          unHide()
          break
  
      default:
          break
  
  
      }
  }
  
  
  @IBAction func rockButton(sender: AnyObject) {
  
      a == 0
      randomChoice()
      gameOn()
  
  }
  
  
  @IBAction func paperButton(sender: AnyObject) {
  
      a == 1
      randomChoice()
      gameOn()
  }
  
  
  
  @IBAction func scissorsButton(sender: AnyObject) {
  
      a == 2
      randomChoice()
      gameOn()
  
  }
  
  
  
  }
  </code></pre>