home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / Tutorial / Cookbook / 29.Dice / Dice.m < prev    next >
Encoding:
Text File  |  1993-01-18  |  562 b   |  46 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "Dice.h"
  5. #import <stdio.h>
  6. #import <appkit/Form.h>
  7.  
  8. extern int getrand(int MaxVal);
  9.  
  10.  
  11. @implementation Dice
  12.  
  13. + new
  14. {
  15.     self = [super new];
  16.     maxValue = 6;
  17.     return self;
  18. }
  19.  
  20. - setValue:anObject
  21. {
  22.     value = anObject;
  23.     return self;
  24. }
  25.  
  26. - maxValue:sender
  27. {
  28.     maxValue = [sender floatValue];
  29.     if (maxValue < 0) {
  30.         printf("bad value");
  31.         // NXAlert("bad value");
  32.     }
  33.     return self;
  34. }
  35.  
  36. - roll:sender
  37. {
  38.     dieValue = getrand(maxValue);
  39.     printf("%d\n", dieValue);
  40.     [value setFloatValue: dieValue ];
  41.     return self;
  42. }
  43.  
  44.  
  45. @end
  46.