• elevator-beta版模型初现


    结对开发:汪洋,辛垧

        继洋哥发表电梯开发阿尔法版后,终于迎来了我们的beta版,好不容易啊,继上一次实现电梯的初始化,run()方法的实现,判断每层上下楼的人数是否符合要求后,我们又升级了最大楼层如下:

     public int maxCount()
            {
                int max=0;
                for (int i = 0; i < 21; i++)
                {
                    if (Pe_req_count[i] == 1||El_run_count[i]==1)
                    {
                        max = i;
                    }
                }
                if (El_stay_floor > max)
                    max = El_stay_floor;
                return max;
            }

    与此同时也完成了每部电梯到达目标楼层的时间的实现:

      public int Time(int Pe_stay_floor,int pgo )
            {
                int i,count=0;
                int floor_gap=0;
                maxCount();
                if (El_go_diraction == 1)
                {
                    if (Pe_stay_floor >= El_stay_floor)
                    {
                        if (pgo == 1)
                        {
                            floor_gap = Pe_stay_floor - El_stay_floor;
                            //the floor which the elevator possibly stopped
                            for (i = El_stay_floor; i <= Pe_stay_floor; i++)
                            {
                                if (El_run_count[i] == 1)
                                {
                                    count++;
                                }
                            }
                        }
                        else if (pgo == -1)
                        {
                            floor_gap = 2 * maxCount() - El_stay_floor - Pe_stay_floor;
                            for (i = El_stay_floor; i <=maxCount(); i++)
                            {
                                if (El_run_count[i] == 1)
                                {
                                    count++;
                                }
                            }
                        }
                       
                    }
                    else
                    {
                        if (pgo == -1)
                        {
                            floor_gap = 2 * maxCount() - El_stay_floor - Pe_stay_floor;
                            //abc
                            for (i = Pe_stay_floor; i <= 20; i++)
                            {
                                if (El_run_count[i] == 1)
                                    count++;
                            }
                        }
                        else if (pgo == 1)
                        {
                            floor_gap = 2 * maxCount() - El_stay_floor + Pe_stay_floor;
                            for (i = 0; i <= 20; i++)
                            {
                                if (El_run_count[i] == 1)
                                    count++;
                            }
                        }
                        
                    }
                }
                else if (El_go_diraction == -1)
                {
                    
                        if (Pe_stay_floor <= El_stay_floor)
                        {
                            if(pgo==-1)
                            {
                                floor_gap = El_stay_floor - Pe_stay_floor;
                                for (i = Pe_stay_floor; i <= El_stay_floor; i++)
                                {
                                    if (El_run_count[i] == 1)
                                        count++;
                                }
                            }
                            else if(pgo==1)
                            {
                                floor_gap = El_stay_floor + Pe_stay_floor;
                                for (i =0; i <= El_stay_floor; i++)
                                {
                                    if (El_run_count[i] == 1)
                                        count++;
                                }
                            }
    
                        }
                        else
                        {
                            if(pgo==-1)
                            {
                                floor_gap = 2 * maxCount() + El_stay_floor - Pe_stay_floor;
                                for (i = 0; i <=20; i++)
                                {
                                    if (El_run_count[i] == 1)
                                        count++;
                                }
                            }
                            else if(pgo==1)
                            {
                                floor_gap = El_stay_floor + Pe_stay_floor;
                                for (i = 0; i <= Pe_stay_floor; i++)
                                {
                                    if (El_run_count[i] == 1)
                                        count++;
                                }
                            }
                        }
                  
                }
                El_alltime = floor_gap * El_run_time_one + count * El_stay_time;
                return El_alltime;
            }
        }
        
    }

    以上为每部电梯到达目标楼层的最短时间,虽然看起来代码很多,但是基本思想四部电梯都是一样的

    现在展现给大家我们目前为止设计好的界面:

    嗯,累了好几天了,来看看我们这几天的分工吧:

    时间 3.17   4:15-5:30 3.18   7:00-8:30 3.19   3:30-4:50 3.20  7:19-9:00
    汪洋 电梯到达目标楼层时间的初步实现 电梯到达目标楼层时间的实现 四部电梯最短时间 最终功能的完善,修改博客
    辛垧 最大楼层的改进 电梯到达目标楼层的实现 界面完善 撰写博客

    我们的电梯调度系统除了界面设计基本完工了,大家敬请期待我们最后的成果吧!

  • 相关阅读:
    【leetcode】Binary Search Tree Iterator
    【leetcode】Palindrome Partitioning II
    【leetcode】Best Time to Buy and Sell Stock III
    【leetcode】Best Time to Buy and Sell Stock II
    【leetcode】Longest Consecutive Sequence
    【leetcode】Factorial Trailing Zeroes
    【leetcode】Simplify Path
    【leetcode】Generate Parentheses
    【leetcode】Combination Sum II
    【leetcode】Combination Sum
  • 原文地址:https://www.cnblogs.com/xinshang/p/3614725.html
Copyright © 2020-2023  润新知