Pair-Pair programming elevator

Source: Internet
Author: User

Elevator Dispatch

Pairing partner: Zhu Min Fu http://http://www.cnblogs.com/zhumf/

Existing new office building, a total of 21 floors, a total of four elevators, all elevators basic parameters are shown in the following table:

Elevator number

Service Floors available

Maximum number of passengers

Maximum Load weight

1

All floors

10

Approx.

2

Single layer

10

Approx.

3

Double

20

Approx.

4

All floors

20

Kg

The terms of use are as follows:

1, the floor number is 0~20, of which No. 0 is the basement layer;

2. Elevators with floor restrictions are not docked in the response floor, such as a single double layer;

3, all elevators with unified button control

Please design and implement an elevator control program according to the above requirements, if there is a graphical display is better.

Program Analysis

First run, the middle of the textbox shows the initial floor of the elevator, the button below is the user's floor, the top is the choice of the use of the elevator number.

Assuming that the person is on the 15 floor, click 15, the elevator is going up, or 0.

 Public Static classQuanju { Public Static intFlot =0;//dianti suo zai louceng!             Public Static intFlag =0;//Running State             Public Static intNum_flot =0;  Public Static intor =2;//0 is up! 1 for the next! 2 is still             Public Static intFLOT1 =0;  Public Static intFlot2 =0;  Public Static intFLOT3 =2;  Public Static intFLOT4 =0; }

Less than the floor buttons on the floor of the elevator are not responding.

Reach level 15, open the door! And resets the floor buttons that prohibit responses.

The implementation is done by adding 4 timer controls to the window, respectively controlling the corresponding elevator runs in the control, where the statements are similar to the 4 timer events

Private voidTimer1_Tick (Objectsender, EventArgs e) {            if(Quanju.flag = =0)//not here .            {                intA =Quanju.flot; Quanju.num_flot=A; if(A > Quanju.flot1 && quanju.flot1 < +) {quanju.or=0;//is upTextBox1.Text =convert.tostring (QUANJU.FLOT1); QUANJU.FLOT1++; }                Else if(A < QUANJU.FLOT1 && quanju.flot1 >-1) {quanju.or=1;//is downTextBox1.Text =convert.tostring (QUANJU.FLOT1); QUANJU.FLOT1--; }                Else if(A = =quanju.flot1) {quanju.or=2;//is opening the doorTextBox1.Text =convert.tostring (QUANJU.FLOT1); Timer1. Enabled=false;//Turn off the timerQuanju.flag =1; }            }            if(Quanju.flag = =1)//arrival at the designated floor{TextBox1.Text="It 's Open!"; Quanju.flag=0;//can runQuanju.or =2;//StationaryButton2. Enabled =true; Button6. Enabled=true; Button7. Enabled=true; Button8. Enabled=true; }        }

And then the elevator. If it is up, it should be forbidden to respond to floor buttons that are lower than the elevator floor.

Private voidButton2_Click (Objectsender, EventArgs e) {            if(quanju.or==0)//Shang            {                //buttons that are lower than the current floor do not respond                if(int. Parse (button2. Text) <=quanju.flot1) {button2. Enabled=false; }              }            Else if(Quanju.or = =1)//Xia            {                //buttons that are higher than the current floor do not respond                if(int. Parse (button2. Text) >=quanju.flot1) {button2. Enabled=false; }            }            Else  //the static state transmits this button floor{Quanju.flot=int. Parse (button2.             Text); }        }

Finally, the top choice is to use the elevator number. Event is the start Timer control.

 Public void button1_click (object  sender, EventArgs e)        {                true;        }
Summarize

In this trooped programming process, I deeply appreciate the importance of team programming, the collective wisdom is infinite, the programming of Zhu Fu is the main, I followed a lot of knowledge.

Pair-Pair programming elevator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.