Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://vk.com/evgenykravchenko0
- ___ ___ ___
- / /\ ___ / /\ / /\
- / /:/_ /__/\ / /:/_ / /:/_
- / /:/ /\ \ \:\ / /:/ /\ / /:/ /\
- / /:/ /:/_ \ \:\ / /:/_/::\ / /:/ /:/_
- /__/:/ /:/ /\ ___ \__\:\ /__/:/__\/\:\ /__/:/ /:/ /\
- \ \:\/:/ /:/ /__/\ | |:| \ \:\ /~~/:/ \ \:\/:/ /:/
- \ \::/ /:/ \ \:\| |:| \ \:\ /:/ \ \::/ /:/
- \ \:\/:/ \ \:\__|:| \ \:\/:/ \ \:\/:/
- \ \::/ \__\::::/ \ \::/ \ \::/
- \__\/ ~~~~ \__\/ \__\/
- ___
- /__/\ ___ ___
- \ \:\ / /\ / /\
- \ \:\ / /:/ / /:/
- _____\__\:\ /__/::\ /__/::\
- /__/::::::::\ \__\/\:\__ \__\/\:\__
- \ \:\~~\~~\/ \ \:\/\ \ \:\/\
- \ \:\ ~~~ \__\::/ \__\::/
- \ \:\ /__/:/ /__/:/
- \ \:\ \__\/ \__\/
- \__\/
- import UIKit
- class ViewController: UIViewController {
- var numberFromScreen: Double = 0
- var firstNum: Double = 0
- var mathSign: Bool = false
- var operation:Int = 0
- @IBOutlet weak var result: UILabel!
- @IBOutlet weak var button: UIButton!
- @IBAction func digits(_ sender: UIButton) {
- if mathSign {
- result.text = String(sender.tag)
- mathSign = !mathSign
- }
- else {
- result.text = result.text! + String(sender.tag)
- }
- numberFromScreen = Double(result.text!)!
- }
- @IBAction func buttonsOperation(_ sender: UIButton) {
- if result.text != "" && sender.tag != 10 && sender.tag != 15 {
- firstNum = Double(result.text!)!
- operation = sender.tag
- mathSign = true
- }
- else if sender.tag == 15 {
- switch operation {
- case 11:
- result.text = String(firstNum / numberFromScreen)
- break
- case 12:
- result.text = String(firstNum * numberFromScreen)
- break
- case 13:
- result.text = String(firstNum - numberFromScreen)
- break
- case 14:
- result.text = String(firstNum + numberFromScreen)
- break
- case 17:
- result.text = String(firstNum);
- break
- default:
- break
- }
- }
- else if sender.tag == 10 {
- result.text = ""
- firstNum = 0
- numberFromScreen = 0
- operation = 0
- }
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- //button.layer.cornerRadius = 47
- // Do any additional setup after loading the view.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement