home *** CD-ROM | disk | FTP | other *** search
- // %PARAMETERS = "CH16LIST C:\UT2004"
- //Identifies the package
- //CH16_03LIST.uc
-
- class CH16_03LIST extends Commandlet;
-
- //#1
- //Set up an enumeration at class scope
- enum COMPASS
- {
- EAST, //sequential numbering begins at 0
- NORTH_EAST,
- NORTH,
- NORTH_WEST,
- WEST,
- SOUTH_WEST,
- SOUTH,
- SOUTH_EAST //final enumerated value is 7
- };
-
- //#2
- //Declare array at the class scope
- var Array<float> rgCompassDegrees;
-
-
- function int Main(string Args){
-
- local int iRand;
- local int iCtr;
-
- // Initialize elements of the array at the local scope
- rgCompassDegrees[0] = 0;
- rgCompassDegrees[1] = 45;
- rgCompassDegrees[2] = 90;
- rgCompassDegrees[3] = 135;
- rgCompassDegrees[4] = 180;
- rgCompassDegrees[5] = 225;
- rgCompassDegrees[6] = 270;
- rgCompassDegrees[7] = 315;
-
- iCtr = 0;
-
- //#3
- while(iCtr <= COMPASS.SOUTH_EAST){
- // Initialize the random identifier
- iRand = Rand(COMPASS.SOUTH_EAST + 1);
-
- //#4
- switch(iRand){
- case COMPASS.EAST:
- Log(Chr(10) $ " Go East! Degrees: "
- //#5
- //Retrieve the associated integer
- $ getDegrees(COMPASS.EAST) );
- break;
- case COMPASS.NORTH_EAST:
- Log(Chr(10) $ " Go North East! Degrees: "
- $ getDegrees(COMPASS.NORTH_EAST) );
- break;
- case COMPASS.NORTH:
- Log(Chr(10) $ " Go North! Degrees: "
- $ getDegrees(COMPASS.NORTH) );
- break;
- case COMPASS.NORTH_WEST:
- Log(Chr(10) $ " Go North West! Degrees: "
- $ getDegrees(COMPASS.NORTH_WEST) );
- break;
- case COMPASS.WEST:
- Log(Chr(10) $ " Go West! Degrees: "
- $ getDegrees(COMPASS.WEST) );
- break;
- case COMPASS.SOUTH_WEST:
- Log(Chr(10) $ " Go South West! Degrees: "
- $ getDegrees(COMPASS.SOUTH_WEST) );
- break;
- case COMPASS.SOUTH:
- Log(Chr(10) $ " Go South! Degrees: "
- $ getDegrees(COMPASS.SOUTH) );
- break;
- case COMPASS.SOUTH_EAST:
- Log(Chr(10) $ " Go South East! "
- $ getDegrees(COMPASS.SOUTH_EAST));
- break;
- };
-
- iCtr++;
- }//end while
-
- return 0;
- }//end Main()
-
-
- // #6
- //COMPASS data type as the argument
- function int getDegrees(COMPASS com){
- return rgCompassDegrees[com];
- }
-
-