Pair Programming-elevator Scheduling
12061181 Gao mengye
12061182 Hao Qian
1. Advantages and Disadvantages of Pair programming:
Advantage: You can give full play to the advantages of two people. Each person is good at different places, and the efficiency of cooperation between two people will be higher.
Disadvantage: if two people have a big difference in strength or have incorrect attitudes and cannot communicate well, the task will fail.
2. Advantages and Disadvantages:
Gao mengye: he can come up with various algorithms. Relatively weak hands-on capabilities.
Hao Qian: strong sense of time; weak code ability. It is not very meticulous to do things.
3. Photos of cooperative programming
4. Design by contract, code contract
Assertion is the core of contractual design ). The so-called "assertion" refers to a Boolean statement that is always true. If it is not true, the program will inevitably have errors. It uses three types of assertions: Post-conditions, pre-conditions, and invariants ).
Due to the Information Hiding principle, we do not know the details of an interface's internal implementation when calling it. In order to use the interface smoothly, the prerequisites must be met first. This prerequisite refers to the desired environment before the operation is executed. After the prerequisite interface is successfully used, a subsequent condition is obtained, that is, after the operation is completed. Constants are class assertions that must be met whether or not certain operations can be called on the object.
5. algorithm ideas:
When the elevator stops: if there is a person in the elevator, the passengers on the floor will leave the elevator and dispatch the Request closest to the current floor. If no one is in the elevator, select the request to wait for the queue to be closest to the current floor. If the waiting queue is empty, the elevator will stop.
When the elevator is in motion: Determine whether there are external requests and internal requests for this layer on each layer, and whether the time is within this period. If the above conditions are met, pick up the people, otherwise, it is executed sequentially.
6. unittest
Pair project elevator