• swift手记-4


    //
    //  ViewController.swift
    //  learn4
    //
    //  Created by myhaspl on 16/1/23.
    //  Copyright (c) 2016年 myhaspl. All rights reserved.
    //
    
    import Cocoa
    
    class ViewController: NSViewController {
        var fifoquene=[Int]()
        var lifoquene=[Int]()
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            // Do any additional setup after loading the view.
        }
    
        override var representedObject: AnyObject? {
            didSet {
            // Update the view, if already loaded.
            }
        }
        
        @IBOutlet weak var inputnum1: NSTextField!
        @IBOutlet weak var inputnum2: NSTextField!
        @IBOutlet weak var fifostate: NSTextField!
        @IBOutlet weak var lifostate: NSTextField!
        
        @IBAction func lifopop(sender: AnyObject) {
            let messagebox:NSAlert=NSAlert()
            if lifoquene.count>0{
                let mynum=lifoquene.removeLast()
                lifostate.stringValue="后进先出"+"  "
                for num in lifoquene{
                    lifostate.stringValue=lifostate.stringValue+String(num)+"  "
                }
                messagebox.messageText="您取出了"+String(mynum)
            }
            else{
                messagebox.messageText="队列为空"
            }
            messagebox.alertStyle=NSAlertStyle.InformationalAlertStyle
            messagebox.runModal()
        }
        
        @IBAction func lifopush(sender: AnyObject) {
            if let mynum=inputnum2.stringValue.toInt(){
                lifoquene.append(mynum)
                lifostate.stringValue+="  "+String(mynum)
            }
        }
        @IBAction func fifopop(sender: AnyObject) {
            let messagebox:NSAlert=NSAlert()
            if fifoquene.count>0{
                let mynum=fifoquene.removeAtIndex(0)
                fifostate.stringValue="先进先出"+"  "
                for num in fifoquene{
                    fifostate.stringValue=fifostate.stringValue+String(num)+"  "
                }
                messagebox.messageText="您取出了"+String(mynum)
            }
            else{
                messagebox.messageText="队列为空"
            }
            messagebox.alertStyle=NSAlertStyle.InformationalAlertStyle
            messagebox.runModal()
        }
        @IBAction func fifopush(sender: AnyObject) {
            if let mynum=inputnum1.stringValue.toInt(){
                fifoquene.append(mynum)
                fifostate.stringValue+="  "+String(mynum)
            }
        }
        
    }
    

    本博客全部内容是原创,假设转载请注明来源

    http://blog.csdn.net/myhaspl/



  • 相关阅读:
    Bit Calculation
    Create ArcGIS maps in Power BI Desktop
    Power Apps visual for Power BI
    Create Power BI visuals by using Python
    运行 R 脚本
    Introduction to ASP.NET Core Blazor
    Tips and tricks for color formatting in Power BI
    Sharepoint Create, Update, and Delete List Items
    Power BI Office Online Server
    jQuery Organization Chart
  • 原文地址:https://www.cnblogs.com/zsychanpin/p/7103499.html
Copyright © 2020-2023  润新知