• 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/



  • 相关阅读:
    2018杭州初雪
    李宗盛
    张爱玲(句子迷)
    RFBnet论文笔记
    AXI总线简介、ID分析、DMA、Vivado烧录、系统集成
    axi总线之零:概述
    怎么理解 Redis 事务?
    Redis 集群最大节点个数是多少?
    怎么测试 Redis 的连通性?
    Redis 集群如何选择数据库?
  • 原文地址:https://www.cnblogs.com/zsychanpin/p/7103499.html
Copyright © 2020-2023  润新知