home *** CD-ROM | disk | FTP | other *** search
/ UnrealScript Game Programming All in One / UnrealScriptGameProgrammingAllInOne.iso / UGPAIOListings / UGPAIOListingsCh09 / CH09LIST / Classes / CH09_05LIST.uc < prev    next >
Encoding:
Text File  |  2006-01-27  |  2.0 KB  |  64 lines

  1.   // %PARAMETERS = "CH09LIST C:\UT2004"
  2.   //  Identifies the package
  3.   //  CH09_05LIST.uc
  4.  
  5.  
  6.   class CH09_05LIST extends Commandlet;
  7.  
  8.     // #1
  9.     // Declaration of  constants
  10.     // is at the class level
  11.     // Initialize constants as you declare them
  12.  
  13.     const IPLRADIUSOFEARTH = 6357;
  14.     const IEQRADIUSOFEARTH = 6378;
  15.     const REARTHTOSUN = 149597870.7;
  16.     const REARTHTOMOON = 3.84401e6;
  17.     const RAGEOFSOLARSYSTEM = 4.6e9;
  18.     const RAGEOFKNOWNUNIVERSE = 16.5e9;
  19.  
  20.     function int main(string args){
  21.     // #2
  22.     // Alter and display values
  23.       log("CH09_05LIST");
  24.       log("=================Const Data Type Use===============");
  25.       log("Polar radius of earth:       "
  26.                                  @ IPLRADIUSOFEARTH @ "kilometers.");
  27.       log("Equatorial radius of earth:  "
  28.                                  @ IEQRADIUSOFEARTH @
  29.                                                   "kilometers.");
  30.       log("=================================================");
  31.       log("Distance from earth to sun: "
  32.                                  @ REARTHTOSUN @  "kilometers.");
  33.       log("Distance from moon to earth: "
  34.                                  @ REARTHTOMOON @  "kilometers.");
  35.       log("=================================================");
  36.  
  37.       //#5.2 Use of "locally defined constant . . .
  38.       log("Number of planets: "
  39.                                  @ INUMBEROFPLANTS @  ".");
  40.       //#6 calling a function
  41.       showAges();
  42.       return 0;
  43.   }
  44.  
  45.  
  46.   //#3 Second function
  47.   function int showAges(){
  48.  
  49.       //#5.1 Not a good practice . . .
  50.       const  INUMBEROFPLANTS = 9;
  51.       log("Age of the solar system:     "
  52.                                  @ RAGEOFSOLARSYSTEM @
  53.                                                     "years.");
  54.       log("Age of the known universe:   "
  55.                                  @ RAGEOFKNOWNUNIVERSE @
  56.                                                     "years.");
  57.       log("=================================================");
  58.     return 0;
  59.   }
  60.  
  61.  
  62.  
  63.  
  64.