home *** CD-ROM | disk | FTP | other *** search
- // %PARAMETERS = "CH09LIST C:\UT2004"
- // Identifies the package
- // CH09_05LIST.uc
-
-
- class CH09_05LIST extends Commandlet;
-
- // #1
- // Declaration of constants
- // is at the class level
- // Initialize constants as you declare them
-
- const IPLRADIUSOFEARTH = 6357;
- const IEQRADIUSOFEARTH = 6378;
- const REARTHTOSUN = 149597870.7;
- const REARTHTOMOON = 3.84401e6;
- const RAGEOFSOLARSYSTEM = 4.6e9;
- const RAGEOFKNOWNUNIVERSE = 16.5e9;
-
- function int main(string args){
- // #2
- // Alter and display values
- log("CH09_05LIST");
- log("=================Const Data Type Use===============");
- log("Polar radius of earth: "
- @ IPLRADIUSOFEARTH @ "kilometers.");
- log("Equatorial radius of earth: "
- @ IEQRADIUSOFEARTH @
- "kilometers.");
- log("=================================================");
- log("Distance from earth to sun: "
- @ REARTHTOSUN @ "kilometers.");
- log("Distance from moon to earth: "
- @ REARTHTOMOON @ "kilometers.");
- log("=================================================");
-
- //#5.2 Use of "locally defined constant . . .
- log("Number of planets: "
- @ INUMBEROFPLANTS @ ".");
- //#6 calling a function
- showAges();
- return 0;
- }
-
-
- //#3 Second function
- function int showAges(){
-
- //#5.1 Not a good practice . . .
- const INUMBEROFPLANTS = 9;
- log("Age of the solar system: "
- @ RAGEOFSOLARSYSTEM @
- "years.");
- log("Age of the known universe: "
- @ RAGEOFKNOWNUNIVERSE @
- "years.");
- log("=================================================");
- return 0;
- }
-
-
-
-
-