From 8568518b57dba05500b63a4e471f8fa65883d10a Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 21 Nov 2025 22:26:28 +0100 Subject: Add pharo contact book --- .../src/ContactBook/ContactBook.class.st | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 pharo-mooc/contact-book/src/ContactBook/ContactBook.class.st (limited to 'pharo-mooc/contact-book/src/ContactBook/ContactBook.class.st') 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 +] -- cgit v1.2.3