This is TestDieRoller.m in view mode; [Download] [Up]
// // TestDieRoller // #import "DieRoller.h" #import "ElkinsEngine.h" #import <stdio.h> #import <stdlib.h> #define SAMPLES 100000 // // test_dieroller() // int test_dieroller(id roller) { ulong results[100]; int i; // // Test rollDie: // printf("TestDieRoller: Rolling %d 20-sided dice.\n", SAMPLES); for(i = 0; i < 20; i++) results[i] = 0; for(i = 0; i < SAMPLES; i++) (results[[roller rollDie:20] - 1])++; for(i = 0; i < 20; i++) printf("%2d: %d (%f%%)\n", i + 1, results[i], (double)results[i] / (double)SAMPLES * 100); printf("\n\n"); // // Test roll:die: // // // Test rollBest:of:die: // return 0; } // // main() // int main(int argc, char *argv[]) { id myRoller; myRoller = [[DieRoller alloc] initEngineClass:[ElkinsEngine class]]; test_dieroller(myRoller); return 0; } // // End of file. //
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.