home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LANGUAGE / SMALTALK / TEXTBOOK / AP02.ST (.txt) < prev    next >
Text File  |  1997-04-22  |  1KB  |  82 lines

  1.  
  2. 'Smalltalk Textbook Appendix 02'!
  3.  
  4.  
  5.  
  6.  
  7.  
  8. Model subclass: #EngiVariable
  9.     instanceVariableNames: 'value '
  10.     classVariableNames: ''
  11.     poolDictionaries: ''
  12.     category: 'Engi-Kernel'!
  13. EngiVariable comment:
  14. '
  15.  
  16. Engi 0.01 (10 January 1994)
  17. Copyright (C) 1994 by Atsushi Aoki
  18.  
  19. '!
  20.  
  21.  
  22. !EngiVariable methodsFor: 'initialize-release'!
  23.  
  24. initialize
  25.     ^self! !
  26.  
  27. !EngiVariable methodsFor: 'accessing'!
  28.  
  29. value
  30.     ^value!
  31.  
  32. value: newValue 
  33.     self setValue: newValue.
  34.     self changed: #value! !
  35.  
  36. !EngiVariable methodsFor: 'collection accessing'!
  37.  
  38. at: anInteger 
  39.     ^self value at: anInteger!
  40.  
  41. at: anInteger put: anObject 
  42.     self value at: anInteger put: anObject.
  43.     self changed: #at with: anInteger!
  44.  
  45. size
  46.     ^self value size! !
  47.  
  48. !EngiVariable methodsFor: 'private'!
  49.  
  50. setSize: sizeInteger 
  51.     self setValue: (Array new: sizeInteger asInteger)!
  52.  
  53. setValue: newValue 
  54.     value := newValue! !
  55. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  56.  
  57. EngiVariable class
  58.     instanceVariableNames: ''!
  59.  
  60.  
  61. !EngiVariable class methodsFor: 'instance creation'!
  62.  
  63. new
  64.     ^super new initialize!
  65.  
  66. new: size 
  67.     ^super new setSize: size!
  68.  
  69. value: anObject 
  70.     ^self new value: anObject!
  71.  
  72. values: objectCollection 
  73.     | aVariable index |
  74.     aVariable := self new: objectCollection size.
  75.     index := 1.
  76.     objectCollection
  77.         do: 
  78.             [:each | 
  79.             aVariable at: index put: each.
  80.             index := index + 1].
  81.     ^aVariable! !
  82.