diff options
Diffstat (limited to 'pharo-mooc/contact-book/src/ContactBook/ContactBook.class.st')
| -rw-r--r-- | pharo-mooc/contact-book/src/ContactBook/ContactBook.class.st | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/pharo-mooc/contact-book/src/ContactBook/ContactBook.class.st b/pharo-mooc/contact-book/src/ContactBook/ContactBook.class.st new file mode 100644 index 0000000..3c6ef69 --- /dev/null +++ b/pharo-mooc/contact-book/src/ContactBook/ContactBook.class.st @@ -0,0 +1,45 @@ +Class { + #name : 'ContactBook', + #superclass : 'Object', + #instVars : [ + 'contacts' + ], + #category : 'ContactBook', + #package : 'ContactBook' +} + +{ #category : 'demos' } +ContactBook class >> createDefault [ + ^ self new + addContact: (Contact newNamed: 'Damien Cassou' email: 'damien@cassou.me'); + addContact: (Contact newNamed: 'Marcus Denker' email: 'marcus.denker@inria.fr'); + addContact: (Contact newNamed: 'Tudor Girba' email: 'tudor@tudorgirba.com'); + addContact: (Contact newNamed: 'Clara Allende' email: 'clari.allende@gmail.com'); + yourself +] + +{ #category : 'writing' } +ContactBook >> addContact: aContact [ + self contacts add: aContact +] + +{ #category : 'reading' } +ContactBook >> contacts [ + ^ contacts +] + +{ #category : 'initialization' } +ContactBook >> initialize [ + super initialize. + contacts := OrderedCollection new +] + +{ #category : 'deleting' } +ContactBook >> removeContact: aContact [ + self contacts remove: aContact +] + +{ #category : 'initialization' } +ContactBook >> size [ + ^ contacts size +] |
