Advertisement
Guest User

120 11 and 12

a guest
Feb 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. /*
  2.  * One car from EAST, One car from WEST, then 2 cars from EAST
  3.  */
  4. void run11() {
  5.  
  6.     if (Fork() == 0) {
  7.         Delay(10);
  8.         driveRoad(WEST, 60);
  9.         Exit();
  10.     }
  11.  
  12.     //the following two child cars should go back to back
  13.     if (Fork() == 0) {
  14.         Delay(200);
  15.         driveRoad(EAST, 60);
  16.         Exit();
  17.     }
  18.     if (Fork() == 0) {
  19.         Delay(200);
  20.         driveRoad(EAST, 60);
  21.         Exit();
  22.     }
  23.  
  24.     driveRoad(EAST, 60);
  25.     return;
  26.  
  27.  
  28. }
  29. /*
  30.  * 2 cars showing up at once and both yielding to the same car
  31.  * on the opposite side
  32.  */
  33. void run12() {
  34.  
  35.     if (Fork() == 0) {
  36.         driveRoad(EAST, 60);
  37.         Exit();
  38.     }
  39.  
  40.     if (Fork() == 0) {
  41.         driveRoad(EAST, 60);
  42.         Exit();
  43.     }
  44.     if (Fork() == 0) {
  45.         Delay(100);
  46.         driveRoad(WEST, 60);
  47.         Exit();
  48.     }
  49.     driveRoad(EAST, 10);
  50.     return;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement