×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / 请问各位大虾:我在用JAVA编一个电梯控制系统,以CLASS1负责各个电梯的运行,以CLASS2控制中心调度,可如何让CLASS2随时知道各个电梯的运行状态(FLOOR,DIRECTION,MOVE OR STOP)呢?多谢!
    • 在用那本how to program Java书? :-)
      • 不是啦,我在做一个COURSE PROJECT,这本书很好吗?
    • you must have "FLOOR ,DIRECTION, status" attribute in your elevator class, then getXXX();in my opinion, class2 needn't know these information, just tell class1 to do what. class1 determine it.
      • 问题是,如果有人在电梯外某楼按了向上或下的按钮,CLASS2不是要根据各个电梯的运行来决定把这一个REQUEST传给某一个电梯去处理吗?
        • if class2 can directely control the elevator, why you need the class1?
        • In opinion, class2 just forward the request and get result. class1 to prosess the request.
          • Thank you,macsym,i understand CLASS1 just forword the REQUEST to CLASS1 to let CLASS1 to process, but what you mean "get result" here?
            • like "success, fail, true , false". just like you bushed the button, the light turn on.
        • 还有,如果让几部电梯同时运行,互不相干,是不是可以在CLASS1里用几个THREADS来实现,每个THREAD控制一个电梯的MOVEMENT,或是有别的好方法?多谢!
          • yeah, class1 must be muliti-thread
            • you are so warm-hearted,macsym.another question: do you think three classes is enough for this system(CLASS1, CLASS2 plus another class for adminstrator)?
              • plus elevator class
                • but i think CLASS2 is controller and CLASS1 is elevator, or maybe i should be a scheduler? the "elevator class" you mentioned here should include what kind of attributes and methods?
                  • my picture: elevator class, administrator class(muliti-thread), client class(to response and forward request).
                    • forgot it, it's wrong. let me think it
                      • there are two kinds of request, one is outside elevators, the other is inside each elevator, should i combine these two requests inot one class? look forword to your reply.
                        • no, that's diffirent .
                          • so maybe i can use the controller class i mentioned above to respond the outside requests and add a elevator class you mentioned before to deal with inside requests and forowrd them to scheduler class?
                  • you are right!
                    • ? i am confused. at what point i am right?
                      • I need more detail about it, do you have a description about it?
                        • here is the description:
                          this is the elevator control system for 15 floor building with 4 elevators. it runs just like normal elevators system in our real world. My system should provide an outside panel for user to require the UP/DOWN at any floor and also an inside panel to allow user in the elevators to select which floor he head to. The system should move UP/DOWN and STOP at any floor according to boht outside and inside requests. If without response for a outside request within 3 minutes there would be an alarm . Also an administrator paned is needed to control the whole system to stop and restart. My system also need to simulate the movement of the 4 elevators. Is that clear ?
                      • hi, macsym. busy or just mad at my stupid question? anyway, thank for your help and would appreciate your further reply.
                  • CLASS2 is controller and CLASS1 is elevator,
    • hi, macsym, where are you, away. offline, busy, or just mad at my stupid question? anyway, thank fou your help and also wait for your futher reply.
      • CLASS2 is controller and CLASS1 is elevator(maybe thread or threadGroup)
        • "maybe thread or threadGroup"? so you mean i even don't need thread? and also, only these 2 class is enough?
    • I think you can get some idea from MVC pattern.
      Class1 is represent the state of elevator and implement obserable interface. Class2 is a Viewer and Controller responsible for display and control elevator implement observor interface. so the system is more clear.
      • do i have to learn MVC pattern? to design the whole system, write related documents(such as SDD) for submmission, and learn java already almost exaust me.