———— elevator dispatching system for knot-pair Project

Source: Internet
Author: User

This assignment is pair programming, is a small project in front of the team project, is designed to test the team collaboration ability and exercise individual programming ability, actually at first I get this topic thought is a very simple question, because think the elevator operation Way is very "fool", but my teammate Wei Xinlei (HTTP/ Www.cnblogs.com/wxl530/not think so, here really want to thank my teammates, Lei elder sister think too comprehensive! Lei elder sister thought of this project should be the best combination of hardware and software, especially some elevator control overload, graphic display, the sensor must be a hardware implementation, after discussion, I found that I think is really too simple .... (gap = =) but due to the lack of objective conditions (mainly I will not AH = =) Finally we decided to simplify the initial plan, abandon the idea of doing the interface, the realization of basic functions is good.

The first is demand analysis:

1.4 Elevators, each elevator information is different, according to its information, to make the corresponding docking, response

2. How to make the elevator meet the daily needs and make reasonable control

3. Graphic display first let it be as clear as possible with the output

We reached a consensus on how to operate the elevator, because there were only four elevators, so each elevator floor was represented by an array, and the floor was controlled by a rising descent, using the array output. Next is the display problem, because four elevators stop the floor, the number of people are not the same, so you can display in the output, respectively, the elevator running up and down with arrows, docked with underline. But we still encountered a problem, can not control the running time, each layer should be a corresponding variable to control it, this is the elevator ah. Lei elder sister or want to use hardware, for example, with an interrupt to show the elevator running state, but the objective conditions are not allowed AH (in fact, mainly I will not ...) At this time I thought of a very silly method, by entering a fixed instruction to show the control of the elevator operation. Solve this problem, you can operate it.

Summary: This pair programming is a very fresh attempt, the experience I have never had before. With very few team members, only two of them will be in better shape and in a very fast state of entry. Because my character is usually so careless, careless, so this time is very fortunate that my teammates are a careful, meticulous girl, if the full score is 100 points, I want to give LEI sister 99! (Less a point afraid of his pride Qaq) Thank you in this pair of programming to give me the help, also let me realize a lot of I do not find the problem with the short board. Because my usual programming habits are very bad, the basic is to think of where to write, no very clear ideas, the main is his favorite lazy, sit still, but this knot on the job, there are teammates constantly raised points and supervision, two people together to clarify the idea, the effect of more than one. This also gives me more confidence in the next team programming, I believe that our team of six members will work together to make progress!

PS: Below is the source code of our program and run

#include <iostream> #include <string.h> #include <conio.h> #include <windows.h>using namespace Std;char Status[4] = {' _ ', ' ', ' ', '};int elevator[4] = {5,8,13,20};char status_not[4] = {' _ ', ' ', ' ', '};int flag _even = 0, flag_odd = 0, Flag_all_ten = 0, Flag_all_twenty = 0;void display (int a) {HANDLE hOut; COORD pos = {0,0}; /* The starting bit of the cursor (1th column, line 3rd) 0 is 1th column 2 is 3rd row */hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); int i,j;for (i = 0; i < 4; i++) {cout << elevator[i];for (j = 0; J < 4; J + +) {if (i = = a) cout << status[j];elsecout << status_not[j];}} void upstairs (int a) {char m; HANDLE HOut; COORD pos = {0,6};hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); Cin >> m;if (m = ' a ') {elevator[a] = Elevator[a] + 1;status[0] = int;d Isplay ( a);}} void downstairs (int a) {char m; HANDLE HOut; COORD pos = {0,6};hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); Cin >> m;if (m = ' A ') {elevator[a] = Elevator[a]-1;status[0] = Int (+);d isplay (a);}} void lift (int nowfloor,int direction) {int A, B, C, D, Min,floor,peoplecount=0;char m;a = nowfloor-elevator[1];//even B = N OWFLOOR-ELEVATOR[2];//full 10c = nowfloor-elevator[3];//full 20d = nowfloor-elevator[0];//odd if (direction = = 2) {if (a) ; 0) A = 25;if (b > 0) b = 25;if (c > 0) c = 25;if (d > 0) d = 25;a = ABS (a), B = ABS (b), C = ABS (c);D = ABS (d);} if (direction = = 1) {if (a < 0) a = 25;if (b < 0) B = 25;if (c < 0) C = 25;if (d < 0) d = 25;} if (b >= c) min = C;elsemin = B;if (b = = && c = =) min = 22;if (a% 2 = 0) {if (d% 2 = = 0) {if (min >= d) min = D;}} if (d% 2 = 0) {if (a% 2 = = 0) {if (min >= a) min = A;}} if (nowfloor% 2 = = 0) {if (min = = a&&flag_even==0) {if (elevator[1] = = Nowfloor) {if (direction = = 1) {Status[0] = I NT (24);} ELSE{STATUS[0] = int (25);} Display (1);} for (; elevator[1]! = Nowfloor;) {if (direction = = 1) upstairs (1); Elsedownstairs (1);} HANDLE HOut; COORD pos = {0,7}; /* The starting bit of the cursor (1th column, line 3rd) 0 is 1th column 2 is 3rd row */hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); cout << "Please enter the number of people, the range is 0~20"; cin >> Peoplecount;peoplecount + = Peoplecount if (Peoplecount >) cout << "The number of people is full \" Else{cout << "has reached the current floor, please enter the destination floor, the range is 0~20"; Cin >> Floor;while (f Loor% 2! = 0) {HANDLE hOut; COORD pos = {0,8}; /* The starting bit of the cursor (1th column, line 3rd) 0 is 1th column 2 is 3rd row */hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); cout << "\ n"; cout << "The elevator only stops at even levels"; Cin >> Floor;} for (; elevator[1]! = floor;) {if (direction = = 1) upstairs (1); Elsedownstairs (1);} STATUS[0] = Int (UP);d isplay (1);}} else if (nowfloor% 2 = 0) {if (min = = d&&flag_odd = 0) {if (elevator[0] = = Nowfloor) {if (direction = = 1) {Status [0] = int (24);} ELSE{STATUS[0] = int (25);} Display (0);} for (; Elevator[0]! = Nowfloor;) {if (direction = = 1) upstairs (0); elsedownstairs (0);} HANDLE HOut; COORD pos = {0,7}; /* The starting bit of the cursor (1th column, line 3rd) 0 is the 1th column 2 is the 3rd row */hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); cout << "Please enter the number of people, the range is 0~10"; cin >> Peoplecount;peoplecount + = Peoplecount if (Peoplecount >) cout << "The number of people is full \" Else{cout << "has reached the current floor, please enter the destination floor, the range is 0~20"; Cin >> Floor;while (f Loor% 2 = = 0) {HANDLE hOut; COORD pos = {0,8}; /* The starting bit of the cursor (1th column, line 3rd) 0 is 1th column 2 is 3rd row */hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); cout << "\ n"; cout << "The elevator stops at odd levels only \ n"; cin >> Floor;} for (; elevator[0]! = floor;) {if (direction = = 1) upstairs (0); elsedownstairs (0);} STATUS[0] = Int (UP);d isplay (0);}} if (min = = B&&flag_all_ten = 0) {if (elevator[2] = = Nowfloor) {if (direction = = 1) {status[0] = int (24);} ELSE{STATUS[0] = int (25);} Display (2);} for (; elevator[2]! = Nowfloor;) {if (direction = = 1) upstairs (2); Elsedownstairs (2);} HANDLE HOut; COORD pos = {0,7}; /* The starting bit of the cursor (1th column, line 3rd) 0 is 1th column 2 is 3rd row */hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); cout << "Please enter the number of people, the range is 0~10  "; cin >> Peoplecount;peoplecount + = peoplecount;if (Peoplecount >) cout <<" people are full "; Else{cout << "You have reached the current floor, please enter the destination floor, the range is 0~20"; Cin >> Floor;for (; ELEVATOR[2]! = floor;) {if (direction = = 1) upstairs (2); Elsedownstairs (2);} STATUS[0] = Int (UP);d isplay (2);}} if (min = = C&&flag_all_twenty = 0) {if (elevator[3] = = Nowfloor) {if (direction = = 1) {status[0] = int (24);} ELSE{STATUS[0] = int (25);} Display (3);} for (; Elevator[3]! = Nowfloor;) {if (direction = = 1) upstairs (3); Elsedownstairs (3);} HANDLE HOut; COORD pos = {0,7}; /* The starting bit of the cursor (1th column, line 3rd) 0 is 1th column 2 is 3rd row */hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); cout << "Please enter the number of people, the range is 0~20"; cin >> Peoplecount;peoplecount + = Peoplecount if (Peoplecount >) cout << "The number of people is full \" Else{cout << "has reached the current floor, please enter the destination floor, the range is 0~20"; Cin >> Floor;for (; ELEVATOR[3]! = floor;) {if (direction = = 1) upstairs (3); Elsedownstairs (3);} STATUS[0] = Int (UP);d isplay (3);}} if (min! =) {HANDLE hOut; COORD pos = {0,11}; /* The starting bit of the cursor (1th column, line 3rd) 0 is 1th column 2 is 3rd row */hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); cout << "has reached the destination floor \ n";}} void menu () {int Direction,floor,nowfloor,flag;int i,j;for (i = 0; i < 4; i++) {cout << elevator[i];for (j = 0; J & Lt 4; J + +) {cout << status[j];}} while (1) {HANDLE hOut; COORD pos = {0,2}; /* The starting bit of the cursor (1th column, line 3rd) 0 is 1th column 2 is 3rd row */hout = GetStdHandle (Std_output_handle); SetConsoleCursorPosition (HOut, POS); cout << "\n1. Up 2.down\n "; cout <<" input call floor, range 0~20\n "; Cin >> Direction>>nowfloor;switch (direction) {Case 1:{lift ( Nowfloor,direction); break;} Case 2:{lift (nowfloor,direction); int main () {menu (); return 1;} /*void even (int floor) {int i;for (i = 0; i <; i++) {if (Flag_even = 1) {if (Flag_all_ten = = 1) {if (flag_all_twenty = = 1) continue;elseelevator_all_twenty (floor);} Elseelevator_all_ten (floor);} Elseelevator_even (floor);}} void odd (int floor) {int i;for (i = 0; i <; i++) {if (Flag_all_twenty = = 1) {if (Flag_all_ten = = 1) {if (Flag_all_twenty = = 1) continue;elseelevator_all_twenty (floor);} Elseelevator_all_ten (floor);} Elseelevator_odd (floor);}} void Elevator_even (int floor) {height=get_height ();p Assenger=get_passenger (); if (height <= &&  Passenger <=) {}}void elevator_odd (int floor) {height = get_height ();p Assenger = Get_passenger (); if (height <= 800 && passenger <=)}void elevator_all_ten (int floor) {height = get_height ();p Assenger = Get_passenger (); if (he ight <= && passenger <=)}void elevator_all_twenty (int floor) {height = get_height ();p Assenger = Get_pa Ssenger (); if (height <= && passenger <= 20)}*/

PS again: (almost forgot to attach our work photo ...) (I didn't wash my hair that day don't take offense = =)

———— elevator dispatching system for knot-pair Project

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.