最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何同步两条跑道以便飞机可以使用java着陆?

网站源码admin20浏览0评论
本文介绍了如何同步两条跑道以便飞机可以使用java着陆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我好像有一个小问题.我有一个空中交通管制应用程序,带有 两条跑道,我要在 java 中同步它.这样做是因为,如果 飞机 2 降落而 飞机 1 正在降落,它(飞机 2)不必等待而是可以快速移动到第二跑道着陆.

I seem to have a small problem. I have an Air Traffic Control Application, with two runways which I am to synchronize in java. This is to be done because, if there is a plane two that lands while plane one is in the process of landing, it(plane two) does not have to wait but can quickly move to the runway two to land.

我已经成功同步了一条跑道,我使用了一个ArrayList来存储飞机的详细信息和着陆工作,但是飞机2的着陆需要等待(大约5秒).关于如何同步两条跑道的任何想法?

I have successfully synchronized one runway and I use one ArrayList to store the plane details and the landing works, however landing of plane two will have to wait(about 5 seconds). Any ideas as to, how to synchronize two runways ?

我现在的想法是有两个 ArrayLists(一个 ArrayList(Even) 存储偶数平面,例如平面二、平面四)和另一个 ArrayList(Odd) 存储奇数平面,例如一号机,三号机.然后我可以让 ArrayList (Even) 与第一跑道一起工作,让 ArrayList (Odd) 与第二跑道一起工作(使用我为第一跑道所做的个人同步技术).缺点是,如果我在 ArrayList Odd 中添加 2 个奇数飞机,在 ArrayList 中添加 20 个偶数飞机,当跑道 2 空闲时,它不会被使用.相反,只会使用一号跑道,偶数飞机将不得不等待.

My present idea was to have two ArrayLists(one ArrayList(Even) stores even numbered planes, eg. plane two, plane four) and another ArrayList(Odd) stores odd numbered planes, e.g. plane one, plane three. Then I can make ArrayList (Even) to work with runway one and ArrayList (Odd) to work with runway two(using the individual synchronizaion technique I have done for runway one). The Downside is that, if I add 2 odd numbered planes in ArrayList Odd and 20 even numbered planes in ArrayList, when runway two becomes free, it would not be used. Instead only runway one would be used and the even numbered planes would have to wait.

附注:我明白如果两条跑道都被占用,第三架飞机将不得不等待,但根据标记方案,这是可以接受的.

Side note: I do understand that if both runways are occupied, the third plane will have to wait, but this is acceptable according to the markscheme.

有什么建议吗?

谢谢

推荐答案

要正确执行此操作,您只需要将传入的飞机放入一个队列即可.Java 提供了一个队列实现,我建议你使用它而不是自己滚动.

To do this properly you need to have only one queue that you put the incoming aircraft into. Java provides a queue implementation and I suggest you use it rather than rolling your own.

设置好队列后,您需要两个跑道对象和一个空中交通管制员".空中交通管制员负责检查跑道,如果有空,将飞机从队列中弹出并告诉它着陆.

Once you have the queue set up you need two runway objects and an 'air traffic controller'. The air traffic controller is responsible for checking the runways and if one is available popping a plane off the queue and telling it to land.

这篇关于如何同步两条跑道以便飞机可以使用java着陆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

发布评论

评论列表(0)

  1. 暂无评论