fork download
  1. "============================================================"
  2. " 大学図書館貸出システム"
  3. " Ideone / GNU Smalltalk用"
  4. "============================================================"
  5.  
  6.  
  7. "------------------------------------------------------------"
  8. " Bookクラス"
  9. "------------------------------------------------------------"
  10.  
  11. Object subclass: #Book
  12. instanceVariableNames: 'isbn title author available'
  13. classVariableNames: ''
  14. poolDictionaries: ''
  15. category: 'UniversityLibrary'!
  16.  
  17.  
  18. !Book methodsFor: 'initialization'!
  19.  
  20. initializeISBN: anISBN title: aTitle author: anAuthor
  21. isbn := anISBN.
  22. title := aTitle.
  23. author := anAuthor.
  24. available := true.
  25. ^self
  26. !
  27.  
  28. ! !
  29.  
  30.  
  31. !Book methodsFor: 'accessing'!
  32.  
  33. isbn
  34. ^isbn
  35. !
  36.  
  37. title
  38. ^title
  39. !
  40.  
  41. author
  42. ^author
  43. !
  44.  
  45. isAvailable
  46. ^available
  47. !
  48.  
  49. statusText
  50. available ifTrue: [^'貸出可能'].
  51. ^'貸出中'
  52. !
  53.  
  54. ! !
  55.  
  56.  
  57. !Book methodsFor: 'loan operations'!
  58.  
  59. borrow
  60. available ifFalse: [
  61. self error: 'この図書はすでに貸出中です'
  62. ].
  63.  
  64. available := false.
  65. ^self
  66. !
  67.  
  68. returnBook
  69. available ifTrue: [
  70. self error: 'この図書は貸出されていません'
  71. ].
  72.  
  73. available := true.
  74. ^self
  75. !
  76.  
  77. ! !
  78.  
  79.  
  80. !Book methodsFor: 'printing'!
  81.  
  82. printOn: aStream
  83. aStream nextPutAll: title.
  84. aStream nextPutAll: ' / '.
  85. aStream nextPutAll: author.
  86. aStream nextPutAll: ' [ISBN: '.
  87. aStream nextPutAll: isbn.
  88. aStream nextPutAll: '] '.
  89. aStream nextPutAll: self statusText
  90. !
  91.  
  92. ! !
  93.  
  94.  
  95. "------------------------------------------------------------"
  96. " Memberクラス"
  97. "------------------------------------------------------------"
  98.  
  99. Object subclass: #Member
  100. instanceVariableNames: 'memberId memberName memberType'
  101. classVariableNames: ''
  102. poolDictionaries: ''
  103. category: 'UniversityLibrary'!
  104.  
  105.  
  106. !Member methodsFor: 'initialization'!
  107.  
  108. initializeId: anId name: aName type: aType
  109. memberId := anId.
  110. memberName := aName.
  111. memberType := aType.
  112. ^self
  113. !
  114.  
  115. ! !
  116.  
  117.  
  118. !Member methodsFor: 'accessing'!
  119.  
  120. memberId
  121. ^memberId
  122. !
  123.  
  124. name
  125. ^memberName
  126. !
  127.  
  128. memberType
  129. ^memberType
  130. !
  131.  
  132. typeName
  133.  
Success #stdin #stdout #stderr 0.01s 7916KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
./prog:133: parse error, expected '!'