home *** CD-ROM | disk | FTP | other *** search
/ UnrealScript Game Programming All in One / UnrealScriptGameProgrammingAllInOne.iso / UGPAIOListings / UGPAIOListingsCh18 / CH18LIST / Classes / Cast.uc next >
Encoding:
Text File  |  2006-02-21  |  2.1 KB  |  82 lines

  1. // %PARAMETERS = "CH18LIST C:\UT2004"
  2. //Identifies the package
  3. //Cast.uc
  4.  
  5.  
  6. class Cast extends Commandlet;
  7. //-------------- Attributes -------------------------------
  8. //#1
  9.  var private string szName;
  10.  var private array<string> rgNames;
  11.  var private string szNames;
  12.  var private int iLen;
  13.  
  14. //-------------- init -------------------------------------
  15. //#2 private function
  16.  
  17. private function int init(){
  18.  szName = "Electra";
  19.  szNames = "Orestes Clytemnestra Electra";
  20.  iLen = Split(szNames, " ", rgNames);
  21.  return 0;
  22. }
  23.  
  24. //-------------- showName ---------------------------------
  25. //#3 Call to private function
  26. //Call another function in the class
  27. public function showName(){
  28.   init();
  29.   Log(Chr(10) $ "   showName() scope : " $ szName);
  30. }
  31.  
  32. //-------------- getInnerName ----------------------------
  33. //#4 Assignment locally to global
  34. //Retrieve name from inside the class and
  35. //Provide it to the world outside the class
  36. public function string getInnerName(){
  37.   szName = "Orestes";
  38.   Log(Chr(10) $ "   getInnerName() scope : " $ szName);
  39.   return szName;
  40. }
  41.  
  42. //-------------- getName ----------------------------------
  43. //#5 Standard accessor
  44. public function string getName(){
  45.   return szName;
  46. }
  47.  
  48.  
  49. //-------------- selectListName ---------------------------
  50. //#6 Array accessor function
  51. public function selectListName(int num){
  52.   if(num < iLen){
  53.         szName = rgNames[num];
  54.     }
  55.  }
  56.  
  57. //-------------- setName ----------------------------------
  58. //#7 Standard mutator for current name
  59. public function setName(string name){
  60.   //Take information from the outside
  61.   //world and change the class attribute
  62.   szName = name;
  63. }
  64.  
  65. //-------------- getListLength ----------------------------
  66. //#8 Standard accessor for list length
  67. public function int getListLength(){
  68.   return iLen;
  69. }
  70.  
  71. //-------------- addToList --------------------------------
  72. //#9 mutator for the list
  73. public function addToList(string name){
  74.  //augment class array
  75.  rgNames.Insert(iLen, 1);
  76.  //assign new length back to class attribute
  77.  iLen = rgNames.Length;
  78.  ///add the name
  79.  rgNames[iLen-1] = name;
  80.  //Log("      Added  " $ name );
  81.  
  82. }