fork download
  1. "============================================================"
  2. " 大学図書館 貸出管理システム"
  3. " Ideone / GNU Smalltalk用"
  4. "============================================================"
  5.  
  6.  
  7. "------------------------------------------------------------"
  8. " Bookクラス"
  9. " 図書の書名、著者、ISBN、貸出状態を管理する"
  10. "------------------------------------------------------------"
  11.  
  12. Object subclass: Book [
  13. | isbn title author available |
  14.  
  15. <category: 'UniversityLibrary'>
  16.  
  17. initializeISBN: anISBN title: aTitle author: anAuthor [
  18. isbn := anISBN.
  19. title := aTitle.
  20. author := anAuthor.
  21. available := true.
  22. ^self
  23. ]
  24.  
  25. isbn [
  26. ^isbn
  27. ]
  28.  
  29. title [
  30. ^title
  31. ]
  32.  
  33. author [
  34. ^author
  35. ]
  36.  
  37. isAvailable [
  38. ^available
  39. ]
  40.  
  41. borrow [
  42. available ifFalse: [
  43. self error: 'この図書はすでに貸出中です'
  44. ].
  45.  
  46. available := false.
  47. ^self
  48. ]
  49.  
  50. returnBook [
  51. available ifTrue: [
  52. self error: 'この図書は貸出されていません'
  53. ].
  54.  
  55. available := true.
  56. ^self
  57. ]
  58.  
  59. statusText [
  60. available
  61. ifTrue: [^'貸出可能']
  62. ifFalse: [^'貸出中']
  63. ]
  64.  
  65. printOn: aStream [
  66. aStream
  67. nextPutAll: title;
  68. nextPutAll: ' / ';
  69. nextPutAll: author;
  70. nextPutAll: ' [ISBN: ';
  71. nextPutAll: isbn;
  72. nextPutAll: '] ';
  73. nextPutAll: self statusText
  74. ]
  75. ]
  76.  
  77.  
  78. "------------------------------------------------------------"
  79. " Memberクラス"
  80. " 図書館利用者の情報と利用者区分を管理する"
  81. "------------------------------------------------------------"
  82.  
  83. Object subclass: Member [
  84. | memberId name memberType |
  85.  
  86. <category: 'UniversityLibrary'>
  87.  
  88. initializeId: anId name: aName type: aType [
  89. memberId := anId.
  90. name := aName.
  91. memberType := aType.
  92. ^self
  93. ]
  94.  
  95. memberId [
  96. ^memberId
  97. ]
  98.  
  99. name [
  100. ^name
  101. ]
  102.  
  103.  
Success #stdin #stdout #stderr 0.01s 7920KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
./prog:103: parse error, expected ']'