"============================================================"
" 大学図書館 貸出管理システム"
" Ideone / GNU Smalltalk用"
"============================================================"
"------------------------------------------------------------"
" Bookクラス"
" 図書の書名、著者、ISBN、貸出状態を管理する"
"------------------------------------------------------------"
Object subclass: Book [
| isbn title author available |
<category: 'UniversityLibrary'>
initializeISBN: anISBN title: aTitle author: anAuthor [
isbn := anISBN.
title := aTitle.
author := anAuthor.
available := true.
^self
]
isbn [
^isbn
]
title [
^title
]
author [
^author
]
isAvailable [
^available
]
borrow [
available ifFalse: [
self error: 'この図書はすでに貸出中です'
].
available := false.
^self
]
returnBook [
available ifTrue: [
self error: 'この図書は貸出されていません'
].
available := true.
^self
]
statusText [
available
ifTrue: [^'貸出可能']
ifFalse: [^'貸出中']
]
printOn: aStream [
aStream
nextPutAll: title;
nextPutAll: ' / ';
nextPutAll: author;
nextPutAll: ' [ISBN: ';
nextPutAll: isbn;
nextPutAll: '] ';
nextPutAll: self statusText
]
]
"------------------------------------------------------------"
" Memberクラス"
" 図書館利用者の情報と利用者区分を管理する"
"------------------------------------------------------------"
Object subclass: Member [
| memberId name memberType |
<category: 'UniversityLibrary'>
initializeId: anId name: aName type: aType [
memberId := anId.
name := aName.
memberType := aType.
^self
]
memberId [
^memberId
]
name [
^name
]