home *** CD-ROM | disk | FTP | other *** search
/ UnrealScript Game Programming All in One / UnrealScriptGameProgrammingAllInOne.iso / UGPAIOListings / UGPAIOListingsCh15 / CH15LIST / Classes / CH15_04LIST.uc < prev   
Encoding:
Text File  |  2006-03-08  |  2.8 KB  |  93 lines

  1. // %PARAMETERS = "CH15LIST C:\UT2004"
  2. //Identifies the package
  3. //CH15_04LIST.uc
  4.  
  5. class CH15_04LIST extends Commandlet;
  6.  
  7. function int Main(string Args){
  8.  
  9. //#1
  10. //Define a customer list
  11. const iREPS = 3;
  12. local int iLength, iCtr, iRepCtr, iNum;
  13.  
  14. local Array<string> rgCustomers;
  15. local Array<string> rgSallyCustomers,
  16.                     rgChuCustomers,
  17.                     rgCaesarCustomers;
  18.  
  19. local string szCustomers, szSallyCustomers,
  20.                           szChuCustomers,
  21.                           szCaesarCustomers;
  22. iCtr = 0;  iLength = 0;  iNum = 0;
  23.  
  24. szCustomers = "Ali Mo Stu Ed Ira Abe Todd Ham " $
  25.                "Si Lil Min Lo Dli Regi Cal Hal " $
  26.                "Su Len Joy Jay Xi Chi Tan Nu";
  27.  
  28. //Complete customer list
  29. Split(szCustomers, " ", rgCustomers);
  30.  
  31. Log (Chr(10) $"  Number of customers: " $ rgCustomers.Length $ Chr(10));
  32.  
  33. // #2
  34. iLength = rgCustomers.Length;
  35. iCtr = 0;
  36.  
  37. while(iCtr < iLength){
  38.  
  39.       while(true){
  40.          //Each time through distribute 3 customers
  41.          //Take the first from the waiting list
  42.          //Add it to the end of the queue for each representative
  43.  
  44.          iNum = rgSallyCustomers.Length;
  45.          //Add to Sally
  46.       // #3
  47.          rgSallyCustomers[iRepCtr] =  rgCustomers[0];
  48.          //Add to the display string
  49.          szSallyCustomers @= rgSallyCustomers[iRepCtr];
  50.          rgSallyCustomers.Insert(iNum,1);
  51.          //Remove first waiting
  52.          rgCustomers.Remove(0,1);
  53.  
  54.          //Add to Chu
  55.          rgChuCustomers[iRepCtr] =  rgCustomers[0];
  56.          //Add to the display string
  57.          szChuCustomers @= rgChuCustomers[iRepCtr];
  58.          rgChuCustomers.Insert(iNum,1);
  59.          //Remove first waiting
  60.          rgCustomers.Remove(0,1);
  61.  
  62.          //Add to Caesar
  63.          rgCaesarCustomers[iRepCtr] = rgCustomers[0];
  64.          //Add to the display string
  65.          szCaesarCustomers @= rgCaesarCustomers[iRepCtr];
  66.          rgCaesarCustomers.Insert(iNum,1);
  67.          //Remove first waiting
  68.          rgCustomers.Remove(0,1);
  69.  
  70.          //Increment customer set for representatives
  71.          iRepCtr++;
  72.  
  73.          // #4
  74.          //Break the block for iREPS
  75.          if(iCtr % iREPS == 0 ){
  76.              iCtr += iREPS;
  77.              //Show assigned customers -- account for zero
  78.              if(iCtr != 0){
  79.                 Log("  Sally:  " $ szSallyCustomers $ Chr(10) $
  80.                     "  Chu:    " $ szChuCustomers   $ Chr(10) $
  81.                     "  Caesar: " $ szCaesarCustomers);
  82.              }
  83.              Log ("   " $ Caps("Waiting")  $ Chr(9)  $ Chr(9)
  84.                                      $ Chr(9) $ Chr(9)
  85.                                      $ rgCustomers.Length);
  86.              break;
  87.           }
  88.       }//End inner while
  89. }//end outer while
  90.  
  91.  
  92. return 0;
  93. }