import UIKit
var counter:Int = 0
class ViewController: UIViewController {
@IBOutlet weak var num: UILabel!
@IBOutlet weak var button0: UIButton!
@IBOutlet weak var button1: UIButton!
@IBOutlet weak var button2: UIButton!
@IBOutlet weak var button3: UIButton!
@IBOutlet weak var button4: UIButton!
@IBOutlet weak var button5: UIButton!
@IBOutlet weak var button6: UIButton!
@IBOutlet weak var button7: UIButton!
@IBOutlet weak var button8: UIButton!
@IBOutlet weak var button9: UIButton!
@IBOutlet weak var buttonReturn: UIButton!
@IBAction func button0(_ sender: Any) {
num.text = String(counter * 10)
counter = counter * 10
}
@IBAction func button1(_ sender: Any) {
num.text = String(counter * 10 + 1)
counter = counter * 10 + 1
}
@IBAction func button2(_ sender: Any) {
num.text = String(counter * 10 + 2)
counter = counter * 10 + 2
}
@IBAction func button3(_ sender: Any) {
num.text = String(counter * 10 + 3)
counter = counter * 10 + 3
}
@IBAction func button4(_ sender: Any) {
num.text = String(counter * 10 + 4)
counter = counter * 10 + 4
}
@IBAction func button5(_ sender: Any) {
num.text = String(counter * 10 + 5)
counter = counter * 10 + 5
}
@IBAction func button6(_ sender: Any) {
num.text = String(counter * 10 + 6)
counter = counter * 10 + 6
}
@IBAction func button7(_ sender: Any) {
num.text = String(counter * 10 + 7)
counter = counter * 10 + 7
}
@IBAction func button8(_ sender: Any) {
num.text = String(counter * 10 + 8)
counter = counter * 10 + 8
}
@IBAction func button9(_ sender: Any) {
num.text = String(counter * 10 + 9)
counter = counter * 10 + 9
}
@IBAction func buttonReturn(_ sender: Any) {
num.text = String(counter / 10)
counter = counter / 10
}
override func viewDidLoad() {
super.viewDidLoad()
num.text = String(counter)
button0.setTitle("0",for:UIControl.State.normal)
button1.setTitle("1",for:UIControl.State.normal)
button2.setTitle("2",for:UIControl.State.normal)
button3.setTitle("3",for:UIControl.State.normal)
button4.setTitle("4",for:UIControl.State.normal)
button5.setTitle("5",for:UIControl.State.normal)
button6.setTitle("6",for:UIControl.State.normal)
button7.setTitle("7",for:UIControl.State.normal)
button8.setTitle("8",for:UIControl.State.normal)
button9.setTitle("9",for:UIControl.State.normal)
buttonReturn.setTitle("←",for:UIControl.State.normal)
}
}