亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? simulation.java

?? 一個飛機調度員模擬訓練程序,可以添加跑道數量,控制飛機飛行的速度.默認的密碼可以在AtcSystem類里面修改,其中內置了三個用戶名.這套系統是我和幾個國外同學合力開發的,希望對大家有幫助
?? JAVA
字號:
import java.util.concurrent.*;  
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.InterruptedException;

import java.awt.geom.Line2D.Float;
import java.util.ArrayList;

/**
 * A simulation of an airspace containing aircraft, runways, and queues of aircraft. 
 * 
 * @author James M. Clarke  
 * @version 12/03/2007
 */
    public class Simulation implements Runnable
    {
        // The lists of all the aircraft, runways, and queues in the simulation
        private java.util.List<Aircraft> aircrafts = java.util.Collections.synchronizedList(new ArrayList<Aircraft>());
        private java.util.List<Runway> runways = new ArrayList<Runway>();
        private java.util.List<Queue> queues = new ArrayList<Queue>();
        
        // ConcurrentQueues to communicate through
        // List of events that have happened to planes
        private java.util.Queue<AircraftEvent> aircraftEvents = new ConcurrentLinkedQueue<AircraftEvent>();
        // Aircraft to get the GUI to add to the JList
        private java.util.Queue<Aircraft> toAdd = new ConcurrentLinkedQueue<Aircraft>();
        // Aircraft to get the GUI to remove from the JList
        private java.util.Queue<Aircraft> toRemove = new ConcurrentLinkedQueue<Aircraft>();
        
        // The frequency at which planes appear. A plane will appear every "frequency" units of time.
        private float frequency = 1;
        private int numberOfAircraft;
        private int aircraftRemaining;
        private int collisions;
        private boolean isComplete;
        private int timeTaken;
        
        private Level myLevel;
        
        /**
         * Constructor for Simulation objects. Creates the initial runways and queues.
         */         
        public Simulation(Level inLevel)
        {
            super();
            //Add the default runway and queue to the simulation
            int airspacesize = 500;
            int spacing = airspacesize / (inLevel.getRunways() + 1);
            
            for (int i = 0; i<inLevel.getRunways(); i++) 
            {
                runways.add(new Runway(new Position(265, spacing*(i+1)), (float) Math.PI/2, "Runway " + (i+1))); 
            }
            
            queues.add(new Queue(new Position(400, 250), (float) Math.PI/2)); 
            //convert from seconds to 10ms intervals
            frequency = inLevel.getFrequency()*100F;
            numberOfAircraft = inLevel.getNumberOfAircraft();
            myLevel = inLevel;
        }

        public boolean isFinished()
        {
            return isComplete;
        }
        
        public int getCollisions()
        {
            return collisions;   
        }
        
                public int getTimeTaken()
        {
            return timeTaken;   
        }
        
        /**
         * Accessor method for the list of aircraft being simulated
         * 
         * @return     a list of aircraft being simulated
        */         
        public java.util.List<Aircraft> getAircraft()
        {
            synchronized(aircrafts) 
            {
                java.util.List<Aircraft> temp = new ArrayList<Aircraft>();
                for (Aircraft a : aircrafts)
                {
                    temp.add(a);
                }
                return temp;
            }
        }   
       

        /**
         * Accessor method for the list of runways being simulated
         * 
         * @return     a list of runways being simulated
        */         
        public java.util.List<Runway> getRunways()
        {
                return runways;
        }   
        

        /**
         * Accessor method for the list of queues of aircraft being simulated
         * 
         * @return     a list of queues of aircraft being simulated
        */         
        public java.util.List<Queue> getQueues()
        {
                return queues;
        }
        

        /**
         * Accessor method for the queue of requests from the GUI to change the state of aircraft
         * 
         * @return     a queue of requests to change the state of aircraft
        */         
        public java.util.Queue<AircraftEvent> getAircraftEvents()
        {
                return aircraftEvents;
        }


        /**
         * Accessor method for the queue of aircraft the GUI should add to its list of aircraft.
         * This method is provided so that GUIs which keep a list of aircraft in the simulation only need to add new aircraft, rather than refreshing the entire list.
         * 
         * @return     a queue of aircraft which the GUI should add to its list of aircraft
        */         
        public java.util.Queue<Aircraft> getToAdd()
        {
                return toAdd;
        }
        

        /**
         * Accessor method for the queue of aircraft the GUI should remove from its list of aircraft
         * This method is provided so that GUIs which keep a list of aircraft in the simulation only need to remove aircraft that have been removed, rather than refreshing the entire list.
         * 
         * @return     a queue of aircraft which the GUI should remove from its list of aircraft
        */         
        public java.util.Queue<Aircraft> getToRemove()
        {
                return toRemove;
        }

        /**
         * Adds an aircraft to the simulation. Aircraft are generated in a random position at the edge of the simulation.
        */   
        // Add an aircraft to the simulation
        public void add()
        {
            aircraftEvents.add( new AircraftEvent(null, 999, null) );      
        }      

        /**
         * Returns a random number, where the random numbers have a Poisson distribution with mean "mean".
         * This algorithm is taken from Knuth, "The Art of Computer Programming" volume 2. 
         * @param   mean    the mean of the distribution
         * @return     a random number
        */        
        public static int randomPoisson(int mean)
        {   
            float l = (float) Math.exp(-mean);
            int k = 0;
            float u;
            float p = 1;
            java.util.Random r = new java.util.Random();
        
            while(p>=l)
            {
                k = k+1;
                u = r.nextFloat();
                p = p * u;
            }
            
            return k-1;   
        }        
        
        /**
         * Run the simulation. Every 10 milliseconds, the simulation will move on by one unit of time. 
         * @see java.lang.Runnable
        */  
        // The main loop
        public void run()
        {
            // keep track of how much time has passed
            int elapsed = 0;
            int timeTillNext = 0;
            aircraftRemaining = numberOfAircraft;
            
            try
            {
                while (!isComplete)
                {  
                    
                    // Randomly add planes to the simulation
                    if ((timeTillNext == 0) && (aircraftRemaining > 0)) { add(); aircraftRemaining--; timeTillNext = randomPoisson((int) (frequency/10))*10;}
                    elapsed++;
                    timeTillNext--;
                    
                    // Clear out the pending events queue
                    while (!aircraftEvents.isEmpty())
                    {
                        AircraftEvent e = aircraftEvents.poll();
                        switch (e.getState()) {

                            case AircraftEvent.ADD: Aircraft a = new Aircraft(runways.get(0), queues.get(0)); 
                            synchronized(aircrafts) 
                            {
                                aircrafts.add(a);
                            }
                            toAdd.add(a);
                            break; 

                            case AircraftEvent.LAND:  
                                if (e.getRunway() == null)
                                {
                                    e.getAircraft().land();
                                }
                                else
                                {
                                    e.getAircraft().land(e.getRunway());
                                }
                                
                                break;
                            case AircraftEvent.TURNLEFT:  e.getAircraft().turnLeft(); break;
                            case AircraftEvent.TURNRIGHT:  e.getAircraft().turnRight(); break;
                            case AircraftEvent.GOTOQUEUE:  e.getAircraft().goToQueue(); break;
                            case AircraftEvent.LEAVE:  e.getAircraft().leave(); break;
                        }
                    }
                    

                    // Remove the landed aircraft
                    ArrayList<Aircraft> toKill = new ArrayList<Aircraft>();
                    
                    //Keep track of whether the simulation is finished or not
                    boolean aPlaneNotFinished = false;
                    
                    //Loop through all the aurcraft checking whether we need to do anything with them and whether some are in the simulation
                    synchronized(aircrafts) 
                    {
                        for (Aircraft b : aircrafts)
                        {
                            if (!(b.getState()==7)) {aPlaneNotFinished = true;}
                            if (!(b.getState() == 5) &&!(b.getState()==7))
                            {
                                //check if is landing and is at start of runway
                                if ((b.getState() == 0) && b.isLanded())
                                {
                                    b.touchDown();
                                }
                                
                                //check if is leaving level and is at edge of map
                                if ((b.getState() == 6) && (Position.distance(new Position(250, 250), b.where())>250))
                                {
                                    //add it the list of things to remove
                                    toKill.add(b);
                                    toRemove.add(b);
                                }
                                
                                //check if has reached entry point for the queue
                                if (b.getState() == 3)
                                {
                                    if (b.isAtQueue()) {b.queue();}
                                } 
                                
                                // Animate the planes
                                b.findAngle();
                                b.move();   
                            }
                        }
                        // End the level if everything is finished
                        if (!aPlaneNotFinished) { timeTaken = elapsed; isComplete = true; ATCSystem.getCurrentUser().addResult(new Result(myLevel, timeTaken, collisions));} 
                        
                        // Collision detection - check if the planes have become too close together
                        // For each aircraft 
                        for (Aircraft b : aircrafts)
                        {
                            //which is in the air and have not been destroyed
                            if (!(b.getState()==5)&&!(b.getState()==7))
                            {
                                // check the other aircraft
                                for (Aircraft c : aircrafts)
                                {
                                    //which are in the air
                                    if (!b.equals(c))
                                    {
                                        //which are in the air and have not been destroyed
                                        if (!(c.getState()==5)&&!(c.getState()==7))
                                        {
                                            //to see how far apart they are
                                            if ( (Position.distance(b.where(),c.where())) < 20) 
                                            {
                                                //If the planes have become too close together, destroy both of them
                                                b.destroy();
                                                c.destroy();
                                                collisions++;
                                            }
                                        
                                    
                                        }
                                    }
                                }    
                            }
                        }
                        
                        // remove everything we want to remove
                        aircrafts.removeAll(toKill);
                        
                    }

                    



                
                // wait for 10ms
                Thread.sleep(10);
                }
            }
            
            //If anything goes wrong, we are fucked
            catch (InterruptedException e)
            {
            }       
            
        }
    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产一区二区三| 狠狠色狠狠色综合| 麻豆精品一区二区av白丝在线| 日韩 欧美一区二区三区| 激情综合网av| 成人美女视频在线观看| 欧美日韩国产一二三| 欧美精品一区二区三区高清aⅴ| 国产精品国产自产拍高清av王其| 亚洲在线视频免费观看| 国内精品伊人久久久久影院对白| 国产在线播放一区三区四| 成人av网站免费观看| 欧美丰满一区二区免费视频| 国产亚洲女人久久久久毛片| 亚洲电影你懂得| 99久久综合国产精品| 日韩一区二区三区视频在线观看| 国产精品国产精品国产专区不蜜| 亚洲自拍欧美精品| 大美女一区二区三区| 日韩欧美中文字幕精品| 一区二区三区在线免费| 国产美女一区二区| 9i在线看片成人免费| 精品卡一卡二卡三卡四在线| 亚洲国产精品一区二区www在线| 黄色资源网久久资源365| 欧美影院一区二区| 国产女同互慰高潮91漫画| 日韩电影在线免费| 欧美体内she精高潮| 成人免费视频在线观看| 国产精品91一区二区| 欧美一区二区三区婷婷月色| 丝袜亚洲另类欧美| 欧美一区二区视频在线观看 | 欧美嫩在线观看| 亚洲一级片在线观看| 欧美日韩午夜在线视频| 日本最新不卡在线| 欧美精品一区二区蜜臀亚洲| 国产成人精品亚洲日本在线桃色 | 亚洲欧洲日韩av| 99国产精品久久| 亚洲电影一区二区三区| 欧美日韩和欧美的一区二区| 日日骚欧美日韩| 欧美精品一区二区三区蜜臀| 国产91精品久久久久久久网曝门| 国产精品久久久久影视| 欧美性三三影院| 久久99精品国产麻豆婷婷 | 欧美一级xxx| 国产酒店精品激情| 亚洲老司机在线| 91精品国产麻豆| 国产成人综合精品三级| 一二三区精品视频| 精品少妇一区二区三区在线播放| 国产精品一区二区x88av| 亚洲免费毛片网站| 日韩午夜激情视频| 成人精品视频一区二区三区| 一区二区三区在线视频观看58| 6080午夜不卡| 成人丝袜高跟foot| 青青青爽久久午夜综合久久午夜| 久久久国产午夜精品| 欧美亚洲高清一区| 成人综合婷婷国产精品久久免费| 亚洲最大色网站| 亚洲精品一区二区三区福利| 91国产免费观看| 国产曰批免费观看久久久| 亚洲综合色婷婷| 国产婷婷精品av在线| 欧美高清精品3d| 色综合久久九月婷婷色综合| 蜜桃av一区二区三区电影| 亚洲男帅同性gay1069| 精品国产免费一区二区三区香蕉 | 一区二区免费在线| 久久精品在这里| 欧美电视剧在线看免费| 欧美亚洲国产一区二区三区va| 国产91对白在线观看九色| 美女视频黄免费的久久| 亚洲成人资源网| 亚洲丝袜美腿综合| 久久久91精品国产一区二区三区| 91精品国产免费| 欧美日本在线观看| 一本久久a久久精品亚洲| 国产精品资源在线观看| 蜜臀a∨国产成人精品| 亚洲综合丁香婷婷六月香| 亚洲三级在线播放| 国产精品久久久久影院| 国产情人综合久久777777| 日韩欧美美女一区二区三区| 欧美疯狂做受xxxx富婆| 欧美日韩高清在线| 欧美偷拍一区二区| 欧美三区在线观看| 97久久人人超碰| 91伊人久久大香线蕉| av激情亚洲男人天堂| 成人激情开心网| 国产99精品国产| 成人国产精品免费观看视频| 国产成人午夜高潮毛片| 国产成人精品综合在线观看| 国产毛片一区二区| 国产精品一区二区三区四区 | 成人高清免费观看| 国产成人亚洲综合a∨猫咪| 国产综合久久久久影院| 韩国欧美国产1区| 国产在线日韩欧美| 高清日韩电视剧大全免费| 国产传媒日韩欧美成人| 国产**成人网毛片九色| 99热99精品| 欧美色网站导航| 7777精品伊人久久久大香线蕉完整版 | 激情五月激情综合网| 精品一区二区免费在线观看| 国产一区二区在线免费观看| 国产成人av一区二区三区在线| 国产69精品一区二区亚洲孕妇 | 欧美日韩免费一区二区三区视频| 欧美三级电影网| 日韩欧美www| 中文字幕欧美激情| 亚洲精品日韩综合观看成人91| 亚洲高清视频的网址| 免费成人你懂的| 高清在线观看日韩| 在线观看免费亚洲| 欧美一区2区视频在线观看| 精品国产乱码久久| 亚洲素人一区二区| 日韩精品一区第一页| 国产成人精品亚洲777人妖| 在线看日本不卡| 精品国产伦理网| 一区二区在线观看免费| 麻豆成人av在线| 一本色道久久综合亚洲91| 制服.丝袜.亚洲.中文.综合| 欧美极品xxx| 亚洲大片免费看| 成人午夜视频在线| 欧美一区二区在线免费播放 | 奇米影视一区二区三区小说| 成人动漫在线一区| 欧美一级夜夜爽| 日韩毛片高清在线播放| 蜜臀久久99精品久久久久久9| 成人性生交大片免费看中文网站| 欧美日韩黄色一区二区| 国产精品国产三级国产aⅴ入口| 日本少妇一区二区| 91一区二区在线| 久久精品夜色噜噜亚洲aⅴ| 日韩电影在线观看电影| 91蜜桃传媒精品久久久一区二区| 欧美电影免费提供在线观看| 亚洲在线观看免费视频| 成人一级片在线观看| 久久综合色8888| 免费高清成人在线| 欧美日韩久久久一区| 国产精品久久久久久久久快鸭 | 国产精品久久综合| 激情综合网最新| 欧美一级xxx| 日韩精彩视频在线观看| 91色.com| 亚洲丝袜另类动漫二区| 成人精品视频网站| 精品第一国产综合精品aⅴ| 天堂精品中文字幕在线| 欧美日韩一区二区三区高清| 亚洲欧洲精品一区二区三区不卡| 国产一区二区不卡| 欧美r级电影在线观看| 美女在线视频一区| 日韩午夜在线观看视频| 日韩av不卡在线观看| 91精品国产一区二区| 亚洲成av人片在www色猫咪| 91九色最新地址| 一区二区在线观看免费 | 91香蕉视频mp4| 亚洲情趣在线观看| 在线观看一区二区视频| 又紧又大又爽精品一区二区| 91福利精品第一导航|