Adaptive Programming – Part 11


Início
Continuação da parte 10.

Adaptive Programming

Video locadora

Estrutura de objetos

A operação abaixo lista a hierarquia de objetos.

Abaixo a listagem da estrutura de objetos antes da aplicação ser exercitada (os objetos estão vazios).

A listagem após a aplicação ter incluído dados é muito extensa. Abaixo um trecho da listagem:

Nas listagens acima gostaríamos que os nomes das variáveis de instância aparecessem. Para isso temos que introduzir hooks para o traversal das variáveis de instância (edge prefix e sufix).

Edge hooks

Os blocos passados como prefix e suffix executam a cada objeto visitado. Precisamos de código para executar antes e depois da travessia de uma variável de instância. O método #visit: abaixo incorpora as novas funcionaliades:

A operação para tal é a que está abaixo:

Um trecho da listagem obtida:

Identer

Como apoio à identação criamos a classe Identer.

Abaixo mostramos os principais métodos de Identer:

Modificamos o código de #listarEstruturaObjetos para usar Identer:

Abaixo os file-outs até agora:

Object subclass: #Accumulator
	instanceVariableNames: 'value'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!Accumulator methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/21/2012 22:15'!
value
	^ value! !

!Accumulator methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/21/2012 22:04'!
value: anObject
	value := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Accumulator class
	instanceVariableNames: ''!

!Accumulator class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/21/2012 22:06'!
value: aSmallInteger
	^self new value: aSmallInteger ! !

Object subclass: #Identer
	instanceVariableNames: 'identCount'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!Identer methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/14/2012 22:57'!
ident
	identCount := identCount + 1! !

!Identer methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'!
identation
	|tabs|
	tabs := WriteStream on: String new.
	identCount timesRepeat: [tabs nextPut: Character tab].
	^ tabs contents! !

!Identer methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/14/2012 22:55'!
initialize
	super initialize .
	self reset! !

!Identer methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/14/2012 22:56'!
reset
	identCount := 0! !

!Identer methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/14/2012 23:06'!
unident
	identCount := identCount - 1! !

Object subclass: #Visitor
	instanceVariableNames: 'result'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!Visitor methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/21/2012 08:19'!
result
	^ result! !

!Visitor methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/21/2012 08:19'!
result: anObject
	result := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Visitor class
	instanceVariableNames: ''!

!Visitor class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/21/2012 18:48'!
result: anObject
	^ self new result: anObject.! !

Object subclass: #CRUDGenerator
	instanceVariableNames: 'packageName rootClass'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!CRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/16/2012 16:47'!
createCRUDOperationForClass: aClass
	^ (Operation
			signature: #generate
			 result: [Identer new]
			from: aClass
			edgePrefix: [:visitor :visited :label :aboutVisit| |crudAddSignature elementClass identer identString|
				identer := visitor result.
				identString := identer identString.
				Transcript cr; show: identString; show: visited; space; show: label; space; show: aboutVisit asString.
				(aboutVisit isKindOf: List) ifTrue:[
					self generateCRUDInSample: visited.
					elementClass := aboutVisit elementClass.
					Transcript cr; tab; show: identString; show: elementClass name.
					crudAddSignature := (#add,  elementClass name, ':') asSymbol.
					visited perform: crudAddSignature with: elementClass new
					]
				]
			) compile.! !

!CRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:59'!
generate
		self createCRUDOperationForClass: rootClass.
		Transcript clear.
		rootClass new generate! !

!CRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:46'!
generateAddSourceWithList: aList collectionVaName: aCollectionVarName idSelector: anIdSelector
	^ 'add: anElement
	"CRUD generated code"
	|toAdd|
	toAdd := self getBy: (anElement perform: anElement class idSelector).
	toAdd ifNotNil: [:found|(CannotAddElementAlreadyExists element: found) signal].
	^  :=  add: anElement'
	expandMacrosWith: aList elementClass name with: aCollectionVarName  with: anIdSelector capitalized ! !

!CRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:42'!
generateCRUDInClass: aClass withCollection: aList collectionVarName: aCollectionVarName idSelector: anIdSelector
	aClass compile: (self generateAddSourceWithList: aList collectionVaName: aCollectionVarName idSelector: anIdSelector).
	aClass compile: (self generateGetSourceWithList: aList collectionVarName: aCollectionVarName idSelector: anIdSelector).
	aClass
		compile: (self generateDeleteSourceWithList: aList collectionVarName: aCollectionVarName idSelector: anIdSelector)! !

!CRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:40'!
generateCRUDInSample: aSampleObject
	aSampleObject class allInstVarNames
				do: [:var |
				(aSampleObject respondsTo: var asSymbol)
					ifTrue: [(aSampleObject perform: var asSymbol)
						ifNotNil: [:varValue |
							(varValue isKindOf: List) ifTrue: [
								self generateCRUDInClass: aSampleObject class withCollection: varValue collectionVarName: var idSelector: varValue elementClass idSelector
								]
						]
				]
		].! !

!CRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:54'!
generateDeleteSourceWithList: aList collectionVarName: aCollectionVarName idSelector: anIdSelector
	^ 'deleteBy: anId
	"CRUD generated code"
	(self getBy: anId)
	ifNotNil: [:toDelete| ^  :=  remove: toDelete]
	ifNil: [(CannotDeleteElementNotExists elementId: anId) signal]'
	expandMacrosWith: aList elementClass name with: aCollectionVarName with: anIdSelector capitalized ! !

!CRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:53'!
generateGetSourceWithList: aList collectionVarName: aCollectionVarName idSelector: anIdSelector
	^ 'getBy: anId
	"CRUD generated code"
	|selecteds|
	selecteds :=  select: [:each| (each perform: #) value = anId].
	selecteds ifEmpty: [^ nil].
		^ selecteds first'
	expandMacrosWith: aList elementClass name with: aCollectionVarName with: anIdSelector with: anIdSelector capitalized ! !

!CRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:04'!
rootClass: aClass
rootClass:= aClass ! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

CRUDGenerator class
	instanceVariableNames: ''!

!CRUDGenerator class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:03'!
rootClass: aClass
	^self new
		rootClass: aClass! !

Object subclass: #CRUDManager
	instanceVariableNames: 'collection idSelector'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!CRUDManager methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 20:25'!
addElement: anElement
	^ collection := collection add: anElement! !

!CRUDManager methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:22'!
collection: aDictionary
	collection := aDictionary! !

!CRUDManager methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:08'!
deleteElementById: anId
	^ collection removeKey: anId! !

!CRUDManager methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 13:20'!
getElementById: anId
	^ (collection select: [:each| (each perform: idSelector) = anId]) head! !

!CRUDManager methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:23'!
idSelector: aByteSymbol
	idSelector := aByteSymbol! !

!CRUDManager methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/18/2012 13:19'!
collection
	^ collection! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

CRUDManager class
	instanceVariableNames: ''!

!CRUDManager class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:24'!
collection: aCollection idSelector: aSymbol
	^ self new
		collection: aCollection;
		idSelector: aSymbol

		! !

Object subclass: #Wrapper
	instanceVariableNames: 'prefix suffix'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!Wrapper methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 13:39'!
prefix
	^ prefix! !

!Wrapper methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 13:39'!
prefix: aBlockClosure
	prefix := aBlockClosure ! !

!Wrapper methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:31'!
suffix
	^ suffix! !

!Wrapper methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/15/2012 10:31'!
suffix: anObject
	suffix := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Wrapper class
	instanceVariableNames: 'suffix'!

!Wrapper class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 13:39'!
prefix: aBlockClosure
	^self new
		prefix: aBlockClosure ! !

!Wrapper class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:33'!
suffix: aBlockClosure
	suffix := aBlockClosure ! !

Visitor subclass: #OperationVisitor
	instanceVariableNames: 'operation arguments edgeLabel lastVisited'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 23:12'!
arguments
	^ arguments! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 21:35'!
bypassing
	^ operation bypassing! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 11:58'!
edgePrefix
	^ operation edgePrefix! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 11:59'!
edgeSuffix
	^ operation edgeSuffix! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 08:40'!
hasWrapperIn: aClass
	^ operation hasWrapperInClass: aClass! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 07:12'!
operation: anOperation
	operation := anOperation ! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 11:43'!
prefix
	^ operation prefix! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 21:33'!
result
	^ result! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 21:34'!
result: anObject
	result := anObject! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:25'!
suffix
	^ operation suffix! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 20:19'!
targetClass
	^ operation targetClass! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 13:10'!
visit: visitedObject
	| wrapper |

	"Suffix processing"
	self edgeSuffix ifNotNil: [ :block | block cull: self cull: visitedObject cull: edgeLabel cull: lastVisited].

	"Prefix processing"
	self prefix ifNotNil: [ :block | block cull: self cull: visitedObject ].
	(wrapper := self wrapperFor: visitedObject class name)
		ifNotNil: [ wrapper prefix ifNotNil: [ :prefix | prefix cull: self cull: visitedObject ] ].

	"Traversal"
	visitedObject class = self targetClass
		ifFalse: [
			visitedObject class allInstVarNames
				do: [ :varName |
					varName = #elementClass
						ifFalse: [
							(visitedObject respondsTo: varName asSymbol)
								ifTrue: [
									varName = self bypassing
										ifFalse: [
											(visitedObject perform: varName asSymbol)
												ifNotNil: [ :varValue |
													"Prefix processing"
													edgeLabel := varName.
													self edgePrefix ifNotNil: [ :block | block cull: self cull: visitedObject cull: edgeLabel cull: varValue].
													lastVisited := visitedObject.
													self visit: varValue ] ] ] ] ] ].

	"Suffix processing"
	wrapper ifNotNil: [ wrapper suffix ifNotNil: [ :suffix | suffix cull: self cull: visitedObject ] ].
	self suffix ifNotNil: [ :block | block cull: self cull: visitedObject ]! !

!OperationVisitor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 18:38'!
wrapperFor: aWrappedClassName
	^ operation wrapperFor: aWrappedClassName
! !

!OperationVisitor methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/26/2012 06:01'!
arguments: anObject
	arguments := anObject! !

!OperationVisitor methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/25/2012 12:40'!
operation
	^ operation! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

OperationVisitor class
	instanceVariableNames: 'operation'!

!OperationVisitor class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 21:33'!
forOperation: anOperation
	^ self new
		operation: anOperation;
		result: anOperation result value! !

Object subclass: #AdaptiveBase
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!AdaptiveBase methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 15:09'!
isAbstract
	^ self class isAbstract! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

AdaptiveBase class
	instanceVariableNames: ''!

!AdaptiveBase class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 15:27'!
isAbstract
	| isAbstract |
	isAbstract :=  self allSubclasses isEmpty not.
	isAbstract ifTrue: [
		self allInstances ifNotEmpty: [self error: 'Abstract class ', self name, ' must not have instances']
		].
	^ isAbstract! !

AdaptiveBase subclass: #Value
	instanceVariableNames: 'value typeClass'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!Value methodsFor: 'comparing' stamp: 'FranciscoAryMartins 7/12/2012 07:27'!
= anObject
	"Answer whether the receiver and anObject represent the same object."

	self == anObject
		ifTrue: [ ^ true ].
	self class = anObject class
		ifFalse: [ ^ false ].
	^ value = anObject value! !

!Value methodsFor: 'comparing' stamp: 'FranciscoAryMartins 7/12/2012 07:27'!
hash
	"Answer an integer value that is related to the identity of the receiver."

	^ value hash! !

!Value methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/12/2012 07:27'!
ofType: aClass
	typeClass := aClass! !

!Value methodsFor: 'printing' stamp: 'FranciscoAryMartins 7/15/2012 08:31'!
printOn: aStream
	"Append a sequence of characters to aStream that identify the receiver."

	super printOn: aStream.
	aStream
		nextPutAll: '(';
		print: typeClass;
		nextPutAll: '): '..
	aStream
		print: value asString ! !

!Value methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/12/2012 07:23'!
value
	^ value! !

!Value methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/13/2012 22:20'!
value: anObject
	(typeClass notNil
		and: [(anObject isKindOf: typeClass) not])
				ifTrue: [(ValueTypeClassInvalid expected: typeClass actual: anObject class) signal].
	value := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Value class
	instanceVariableNames: ''!

!Value class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/12/2012 07:24'!
ofType: aClass
	^ self new
		ofType: aClass! !

Value subclass: #NonTerminal
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

AdaptiveBase subclass: #List
	instanceVariableNames: 'elementClass'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!List methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:39'!
add: anElement
	self checkElementClass: anElement.
	^ NonEmptyList head: anElement tail: self! !

!List methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:39'!
checkElementClass: anElement
	elementClass
		ifNotNil: [(anElement isKindOf: elementClass)
				ifFalse: [self error: 'Element must be of class ' , elementClass name]]! !

!List methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/29/2012 22:02'!
elementClass
	^ elementClass! !

!List methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 07:32'!
elementClass: aClass
	elementClass := aClass! !

!List methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 18:38'!
ifEmpty: aBlock
	^ self isEmpty
		ifTrue: [ ^aBlock value ]
		ifFalse: [ self ]! !

!List methodsFor: 'printing' stamp: 'FranciscoAryMartins 7/16/2012 17:28'!
printOn: aStream
	"Append a sequence of characters to aStream that identify the receiver."

	super printOn: aStream.
	aStream
		nextPutAll: '(';
		print: elementClass;
		nextPutAll: ')'! !

List subclass: #EmptyList
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!EmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/8/2012 11:57'!
addAll: aCollection
	"Include all the elements of aCollection as the receiver's elements. Answer
	aCollection. Actually, any object responding to #do: can be used as argument."

	| result |
	result := EmptyList new.
	aCollection do: [:each | result := result add: each].
	^ result! !

!EmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:41'!
append: anElement
	self checkElementClass: anElement.
	^ NonEmptyList head: anElement tail: self! !

!EmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 19:39'!
do: aBlockClosure ! !

!EmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 18:39'!
isEmpty
	^ true! !

!EmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 20:31'!
select: aBlockClosure ! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

EmptyList class
	instanceVariableNames: ''!

!EmptyList class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:17'!
ofType: anElementClass
	^ self new
		elementClass: anElementClass! !

Value subclass: #Terminal
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

Error subclass: #CRUDError
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

CRUDError subclass: #CannotAddElementAlreadyExists
	instanceVariableNames: 'element'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!CannotAddElementAlreadyExists methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/11/2012 07:28'!
element
	^ element! !

!CannotAddElementAlreadyExists methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/11/2012 07:28'!
element: anObject
	element := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

CannotAddElementAlreadyExists class
	instanceVariableNames: ''!

!CannotAddElementAlreadyExists class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/11/2012 07:29'!
element: anObject
	self new
		element: anObject! !

CRUDError subclass: #CannotDeleteElementNotExists
	instanceVariableNames: 'elementId'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!CannotDeleteElementNotExists methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/11/2012 07:29'!
elementId
	^ elementId! !

!CannotDeleteElementNotExists methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/11/2012 07:29'!
elementId: anObject
	elementId := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

CannotDeleteElementNotExists class
	instanceVariableNames: ''!

!CannotDeleteElementNotExists class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/11/2012 09:39'!
elementId: anObject
	^ self new
		elementId: anObject! !

Error subclass: #ValueTypeClassInvalid
	instanceVariableNames: 'actualClass expectedClass'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!ValueTypeClassInvalid methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/12/2012 07:53'!
actual
	^actualClass! !

!ValueTypeClassInvalid methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/12/2012 07:37'!
actual: aSmallIntegerClass
	actualClass := aSmallIntegerClass! !

!ValueTypeClassInvalid methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/16/2012 18:19'!
description
	^ self class name, ' expected: ', expectedClass name , ' actual: ', actualClass name! !

!ValueTypeClassInvalid methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/12/2012 07:53'!
expected
	^ expectedClass! !

!ValueTypeClassInvalid methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/12/2012 07:38'!
expected: aStringClass
	expectedClass := aStringClass! !

!ValueTypeClassInvalid methodsFor: 'printing' stamp: 'FranciscoAryMartins 7/12/2012 07:46'!
printOn: aStream
	"Append a sequence of characters to aStream that identify the receiver."

	super printOn: aStream.
	aStream
		nextPutAll: ' expectedClass: ';
		print: expectedClass.
	aStream
		nextPutAll: ' actualClass: ';
		print: actualClass! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

ValueTypeClassInvalid class
	instanceVariableNames: ''!

!ValueTypeClassInvalid class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/12/2012 07:36'!
expected: expectedClass actual: actualClass
	^ self new
		expected: expectedClass;
		actual: actualClass! !

Object subclass: #Operation
	instanceVariableNames: 'result sourceClass targetClass wrappers visitor signatureSymbol prefix bypassing suffix edgePrefix edgeSuffix'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 13:38'!
addWrapperTo: aClass withPrefix: aBlockClosure
	wrappers at: aClass name asSymbol put: (Wrapper prefix: aBlockClosure) ! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:26'!
addWrapperTo: aClass withSuffix: aBlockClosure
	wrappers at: aClass name asSymbol put: (Wrapper suffix: aBlockClosure) ! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 21:35'!
bypassing
	^ bypassing! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 21:28'!
bypassing: aByteSymbol
	bypassing:=aByteSymbol! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/26/2012 06:11'!
compile
	self compileEntryPoint! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/26/2012 06:11'!
compileEntryPoint
	sourceClass compile: self createEntryPointSource! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 21:29'!
createEntryPointSource
	| sourceCode |
	sourceCode := '
	"Operation entry point generated code"
	| visitor |
	visitor := (Operation atSignature: #) createVisitor.
	visitor arguments: thisContext arguments.
	visitor visit: self.
	^ visitor result value'.
	^ sourceCode expandMacrosWith: (self signatureWithArgumentsFrom: signatureSymbol) with: signatureSymbol

! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 21:25'!
createVisitor
	^ OperationVisitor forOperation: self! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:01'!
edgePrefix
	^ edgePrefix! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 11:32'!
edgePrefix: aBlockClosure
	edgePrefix := aBlockClosure! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:00'!
edgeSuffix
	^ edgeSuffix! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 11:33'!
edgeSuffix: aBlockClosure
	edgeSuffix:=aBlockClosure! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 08:47'!
hasWrapperInClass: aClass
	^ wrappers isEmpty not and: [wrappers includesKey: aClass] ! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 21:23'!
initialize
	wrappers := Dictionary new.! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 11:43'!
prefix
	^ prefix! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 11:39'!
prefix: aBlockClosure
	prefix := aBlockClosure! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 13:35'!
prefixAt: aClassName
	^ (wrappers at: aClassName) prefix! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 12:44'!
result
	^ result! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 06:51'!
result: anObject
	result := anObject ! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 20:52'!
signature: aByteSymbol
	signatureSymbol := aByteSymbol ! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 15:14'!
signatureWithArgumentsFrom: aByteSymbol
	| stream count keywords |
	stream := WriteStream on: ''.
	count := 1.
	keywords := aByteSymbol keywords.
	(keywords size = 1 and: [ (keywords first includes: $:) not ])
		ifTrue: [ ^ keywords first ].
	keywords
		do: [ :keyword |
			stream
				nextPutAll: keyword;
				nextPutAll: ' anObject';
				nextPutAll: count asString;
				nextPutAll: ' '.
			count := count + 1 ].
	^ stream contents! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 06:52'!
sourceClass: aClass
	sourceClass := aClass! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:31'!
suffix
	^ suffix! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:31'!
suffix: aBlockClosure
	suffix := aBlockClosure! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:26'!
suffixAt: aClassName
	^ (wrappers at: aClassName) suffix! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 06:53'!
targetClass: aClass
	targetClass := aClass! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 08:03'!
visitor
	^visitor ! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/10/2012 07:14'!
wrapper: aClass with: aWraperBlock
	| wrapper |
	wrapper := wrappers at: aClass name ifAbsentPut: [ Wrapper new ].
	aWraperBlock value: wrapper! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 18:42'!
wrapperFor: aWrappedClassName
	^ wrappers at: aWrappedClassName ifAbsent: [^ nil]! !

!Operation methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 14:01'!
wrapperTo: aClass with: aWraperBlock
	| wrapper |
	wrapper := wrappers at: aClass name ifAbsentPut: [ Wrapper new ].
	aWraperBlock value: wrapper! !

!Operation methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/25/2012 20:52'!
signature
	^ signatureSymbol! !

!Operation methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/27/2012 20:20'!
targetClass
	^ targetClass! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Operation class
	instanceVariableNames: 'operations'!

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 07:45'!
atSignature: aSignature
	^ operations at: aSignature! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 07:54'!
initialize
	"
	self initialize
	"
	operations := Dictionary new! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/23/2012 07:58'!
registerOperation: anOperation
	operations at: anOperation signature put: anOperation! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:56'!
signature: aByteSymbol from: aSourceClass to: aTargetClass
	^ self
		signature: aByteSymbol
		result: nil
		from: aSourceClass
		bypassing: nil
		to: aTargetClass
		prefix: nil
		edgePrefix: nil
		edgeSuffix: nil
		suffix: nil! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:56'!
signature: aByteSymbol result: anOrderedCollection from: anEmpresaClass bypassing: aByteSymbol4 to: anEmpregadoClass
	^ self
		signature: aByteSymbol
		result: anOrderedCollection
		from: anEmpresaClass
		bypassing: aByteSymbol4
		to: anEmpregadoClass
		prefix: nil
		edgePrefix: nil
		edgeSuffix: nil
		suffix: nil! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 11:14'!
signature: aByteSymbol result: anObject from: aSourceClass bypassing: aByteSymbol4 to: aTargetClass prefix: prefixBlock edgePrefix: edgePrefixBlock edgeSuffix: edgeSuffixBlock suffix: suffixBlock
	| operation |
	operation := self new
		signature: aByteSymbol ;
		result: anObject ;
		sourceClass: aSourceClass ;
		bypassing: aByteSymbol4;
		targetClass: aTargetClass ;
		prefix: prefixBlock;
		edgePrefix: edgePrefixBlock;
		edgeSuffix: edgeSuffixBlock;
		suffix: suffixBlock .

	self registerOperation: operation.
	^ operation! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:25'!
signature: aByteSymbol result: aBlockClosure from: aSourceClass edgeSuffix: anEedgeSuffixBlock
	^ self signature: aByteSymbol result: aBlockClosure from: aSourceClass bypassing: nil to: nil prefix: nil edgePrefix: nil edgeSuffix: anEedgeSuffixBlock suffix: nil ! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:56'!
signature: aByteSymbol result: anObject from: aSourceClass prefix: prefixBlock
	^ self
		signature: aByteSymbol
		result: anObject
		from: aSourceClass
		bypassing: nil
		to: nil
		prefix: prefixBlock
		edgePrefix: nil
		edgeSuffix: nil
		suffix: nil! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 11:29'!
signature: aByteSymbol result: aBlockClosure from: aSourceClass prefix: prefixBlock edgePrefix: edgePrefixBlock edgeSuffix: edgeSuffixBlock suffix: suffixBlock
	^ self signature: aByteSymbol result: aBlockClosure from: aSourceClass bypassing: nil to: nil  prefix: prefixBlock edgePrefix: edgePrefixBlock edgeSuffix: edgeSuffixBlock suffix: suffixBlock ! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:29'!
signature: aByteSymbol result: aBlockClosure from: aSourceClass prefix: prefixBlock edgeSuffix: edgeSuffixBlock suffix: suffixBlock
	^ self signature: aByteSymbol result: aBlockClosure from: aSourceClass bypassing: nil to: nil prefix: prefixBlock edgePrefix: nil edgeSuffix: edgeSuffixBlock suffix: suffixBlock ! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:56'!
signature: aByteSymbol result: aBlockClosure from: aSourceClass prefix: prefixBlock suffix: suffixBlock
	^ self
		signature: aByteSymbol
		result: aBlockClosure
		from: aSourceClass
		bypassing: nil
		to: nil
		prefix: prefixBlock
		edgePrefix: suffixBlock
		edgeSuffix: nil
		suffix: nil! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:23'!
signature: aByteSymbol result: anObject from: aSourceClass to: aTargetClass
	^ self signature: aByteSymbol result: anObject from: aSourceClass to: aTargetClass prefix: nil suffix: nil! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:23'!
signature: aByteSymbol result: anObject from: aSourceClass to: aTargetClass prefix: aBlockClosure
	^ self signature: aByteSymbol result: anObject from: aSourceClass to: aTargetClass prefix: aBlockClosure suffix: nil! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:56'!
signature: aByteSymbol result: anObject from: aSourceClass to: aTargetClass prefix: prefixBlock suffix: suffixBlock
	^ self
		signature: aByteSymbol
		result: anObject
		from: aSourceClass
		bypassing: nil
		to: aTargetClass
		prefix: prefixBlock
		edgePrefix: suffixBlock
		edgeSuffix: nil
		suffix: nil! !

!Operation class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:24'!
signature: aByteSymbol result: anObject from: aSourceClass to: aTargetClass suffix: aBlockClosure
	^ self signature: aByteSymbol result: anObject from: aSourceClass to: aTargetClass prefix: nil suffix: aBlockClosure! !

Object subclass: #PackageCRUDGenerator
	instanceVariableNames: 'packageName'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!PackageCRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 12:35'!
compile
	self generate! !

!PackageCRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 12:35'!
generate
	| sample |
	(SystemNavigation default allClassesInPackageNamed: packageName)
		do: [:class|
			sample := class new.
			self generateCRUDInSample: sample
		]! !

!PackageCRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/11/2012 07:35'!
generateAddSourceWithList: aList collectionVaName: aCollectionVarName idSelector: anIdSelector
	^ 'add: anElement
	"CRUD generated code"
	|toAdd|
	toAdd := self getBy: (anElement perform: anElement class idSelector).
	toAdd ifNotNil: [:found|(CannotAddElementAlreadyExists element: found) signal].
	^  :=  add: anElement'
	expandMacrosWith: aList elementClass name with: aCollectionVarName  with: anIdSelector capitalized ! !

!PackageCRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 12:46'!
generateCRUDInClass: aClass withCollection: aList collectionVarName: aCollectionVarName idSelector: anIdSelector
	aClass compile: (self generateAddSourceWithList: aList collectionVaName: aCollectionVarName idSelector: anIdSelector).
	aClass compile: (self generateGetSourceWithList: aList collectionVarName: aCollectionVarName idSelector: anIdSelector).
	aClass
		compile: (self generateDeleteSourceWithList: aList collectionVarName: aCollectionVarName idSelector: anIdSelector)! !

!PackageCRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:01'!
generateCRUDInSample: aSampleObject
	aSampleObject class allInstVarNames
				do: [:var |
				(aSampleObject respondsTo: var asSymbol)
					ifTrue: [(aSampleObject perform: var asSymbol)
						ifNotNil: [:varValue |
							(varValue isKindOf: List) ifTrue: [
								self generateCRUDInClass: aSampleObject class withCollection: varValue collectionVarName: var idSelector: varValue elementClass idSelector
								]
						]
				]
		].! !

!PackageCRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/11/2012 07:35'!
generateDeleteSourceWithList: aList collectionVarName: aCollectionVarName idSelector: anIdSelector
	^ 'deleteBy: anId
	"CRUD generated code"
	(self getBy: anId)
	ifNotNil: [:toDelete| ^  :=  remove: toDelete]
	ifNil: [(CannotDeleteElementNotExists elementId: anId) signal]'
	expandMacrosWith: aList elementClass name with: aCollectionVarName with: anIdSelector capitalized ! !

!PackageCRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/13/2012 21:19'!
generateGetSourceWithList: aList collectionVarName: aCollectionVarName idSelector: anIdSelector
	^ 'getBy: anId
	"CRUD generated code"
	|selecteds|
	selecteds :=  select: [:each| (each perform: #) value = anId].
	selecteds ifEmpty: [^ nil].
		^ selecteds first'
	expandMacrosWith: aList elementClass name with: aCollectionVarName with: anIdSelector with: anIdSelector capitalized ! !

!PackageCRUDGenerator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 07:14'!
packageName: aByteString
	packageName := aByteString
		! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

PackageCRUDGenerator class
	instanceVariableNames: ''!

!PackageCRUDGenerator class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 07:13'!
packageName: aByteString
	^ self new
		packageName: aByteString ! !

List subclass: #NonEmptyList
	instanceVariableNames: 'head tail'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Core'!

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/8/2012 11:58'!
addAll: aCollection
	"Include all the elements of aCollection as the receiver's elements. Answer
	aCollection. Actually, any object responding to #do: can be used as argument."

	| result |
	result := self.
	aCollection do: [:each | result := result add: each].
	^ result! !

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/29/2012 22:18'!
append: anElement
	^ NonEmptyList head: head tail: (tail append: anElement)! !

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 13:13'!
do: aBlockClosure
	aBlockClosure value: head.
	tail do: aBlockClosure ! !

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 16:13'!
first
	^ head! !

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 13:13'!
head
	^ head! !

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 13:14'!
head: anElement
	head := anElement! !

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 18:39'!
isEmpty
	^ false! !

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/6/2012 12:29'!
remove: anObject
	head = anObject ifTrue: [^ tail].
	^ NonEmptyList head: head tail: (tail remove: anObject)! !

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:17'!
select: aBlockClosure
	| newCollection |
	newCollection := EmptyList ofType: elementClass. .
	self do: [:each | (aBlockClosure value: each) ifTrue: [newCollection := newCollection add: each]].
	^newCollection! !

!NonEmptyList methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 13:19'!
tail: anEmptyList
	tail := anEmptyList! !

!NonEmptyList methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/25/2012 16:58'!
tail
	^ tail! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

NonEmptyList class
	instanceVariableNames: ''!

!NonEmptyList class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 13:19'!
first: anElement rest: aList
	^ self new
		head: anElement;
		tail: aList! !

!NonEmptyList class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/29/2012 22:27'!
head: anElement tail: aList
	^ self new
		head: anElement;
		tail: aList;
		elementClass: aList elementClass! !

Operation initialize!
AdaptiveBase subclass: #Departamento
	instanceVariableNames: 'nome empregados divisoes gerente'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Examples-Model'!

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/21/2012 08:10'!
acceptVisitor: aVisitor
	aVisitor visitDepartamento: self! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
addDivisao: anElement
		"Generated code"
		|toAdd|
		toAdd := self getDivisaoByNome: (anElement perform: anElement class idSelector).
		toAdd ifNotNil: [:found|self error: found asString, 'already exists'].
		^ divisoes := divisoes add: anElement! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
addEmpregado: anElement
		"Generated code"
		|toAdd|
		toAdd := self getEmpregadoByMatricula: (anElement perform: anElement class idSelector).
		toAdd ifNotNil: [:found|self error: found asString, 'already exists'].
		^ empregados := empregados add: anElement! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/24/2012 08:48'!
adicionarDivisao: aDivisao
	^ divisoes := divisoesCrudManager addElement: aDivisao ! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/24/2012 08:50'!
adicionarEmpregado: anEmpregado
	^ empregados := empregadosCrudManager addElement: anEmpregado ! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
deleteDivisaoByNome: anId
		"Generated code"
		|toDelete|
		toDelete := self getDivisaoByNome: anId.
		^ divisoes := divisoes remove: toDelete! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
deleteEmpregadoByMatricula: anId
		"Generated code"
		|toDelete|
		toDelete := self getEmpregadoByMatricula: anId.
		^ empregados := empregados remove: toDelete! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/20/2012 10:19'!
empregadosSalarioMaiorQue: aSmallInteger
	| result |
	result := OrderedCollection new.
	empregados do: [:each| result addAll: (each empregadosSalarioMaiorQue: aSmallInteger)].
	divisoes do: [:each| result addAll: (each empregadosSalarioMaiorQue: aSmallInteger)].
	^ result! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
getDivisaoByNome: anId
		"Generated code"
		|selecteds|
		selecteds := divisoes select: [:each| (each perform: #nome) = anId].
		selecteds ifEmpty: [^ nil].
			^ selecteds first! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
getEmpregadoByMatricula: anId
		"Generated code"
		|selecteds|
		selecteds := empregados select: [:each| (each perform: #matricula) = anId].
		selecteds ifEmpty: [^ nil].
			^ selecteds first! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:17'!
initialize
	empregados := EmptyList  ofType: Empregado.
	divisoes := EmptyList  ofType: Divisao..
! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/17/2012 19:48'!
listarDivisoes
	self divisoes
		do: [:divisao|
			Transcript
				space;
				show: divisao nome
				] ! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 07:40'!
listarEmpregados
	self empregados
		do: [:empregado | Transcript cr; tab;
			show: empregado matricula; space;
			show: empregado nome; space;
			show: empregado salario].
	self divisoes do: [:divisao|
		Transcript cr; show: 'Divisão: '; show: divisao nome.
		divisao listarEmpregados]! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/19/2012 16:28'!
nomesEmpregados
	| result |
	result := OrderedCollection new.
	empregados do: [:each| result addAll: each nomesEmpregados].
	divisoes do: [:each| result addAll: each nomesEmpregados].
	^ result! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/20/2012 07:03'!
numeroEmpregados
	| result |
	result := 0.
	empregados do: [:each| result := result + each numeroEmpregados].
	divisoes do: [:each| result := result + each numeroEmpregados].
	^ result! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'!
printOn: aStream
	super printOn: aStream.
	aStream
		nextPutAll: ': ';
		nextPutAll: nome! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:31'!
recuperarDivisaoNome: aByteString
	^ divisoesCrudManager getElementById: aByteString! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:27'!
recuperarEmpregadoMatricula: aSmallInteger
	^ crudManager getElementById: aSmallInteger! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:32'!
removerDivisaoNome: aString
	^ divisoesCrudManager deleteElementById: aString! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:32'!
removerEmpregadoMatricula: aSmallInteger
	^ empregadosCrudManager deleteElementById: aSmallInteger! !

!Departamento methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/19/2012 07:47'!
todosEmpregados
	| result |
	result := OrderedCollection new.
	empregados do: [:each| result addAll: each todosEmpregados].
	divisoes do: [:each| result addAll: each todosEmpregados].
	^ result! !

!Departamento methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/17/2012 19:33'!
divisoes
	^ divisoes! !

!Departamento methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/14/2012 07:24'!
empregados
	^ empregados! !

!Departamento methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/29/2012 11:23'!
gerente
	^ gerente! !

!Departamento methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/29/2012 11:23'!
gerente: anObject
	gerente := anObject! !

!Departamento methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/16/2012 09:23'!
nome
	^ nome! !

!Departamento methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/16/2012 09:23'!
nome: anObject
	nome := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Departamento class
	instanceVariableNames: ''!

!Departamento class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 16:36'!
idSelector
	^ #nome! !

!Departamento class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/16/2012 09:26'!
nome: aString
	^ self new nome: aString! !

AdaptiveBase subclass: #Divisao
	instanceVariableNames: 'nome empregados gerente'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Examples-Model'!

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 16:41'!
a CRUDGenerator! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/21/2012 08:10'!
acceptVisitor: aVisitor
	aVisitor visitDivisao: self! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
addEmpregado: anElement
		"Generated code"
		|toAdd|
		toAdd := self getEmpregadoByMatricula: (anElement perform: anElement class idSelector).
		toAdd ifNotNil: [:found|self error: found asString, 'already exists'].
		^ empregados := empregados add: anElement! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/24/2012 08:50'!
adicionarEmpregado: anEmpregado
	^ empregados := crudManager addElement: anEmpregado ! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
deleteEmpregadoByMatricula: anId
		"Generated code"
		|toDelete|
		toDelete := self getEmpregadoByMatricula: anId.
		^ empregados := empregados remove: toDelete! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/20/2012 10:22'!
empregadosSalarioMaiorQue: aSmallInteger
	| result |
	result := OrderedCollection new.
	empregados do: [:each| result addAll: (each empregadosSalarioMaiorQue: aSmallInteger)].
	^ result! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
getEmpregadoByMatricula: anId
		"Generated code"
		|selecteds|
		selecteds := empregados select: [:each| (each perform: #matricula) = anId].
		selecteds ifEmpty: [^ nil].
			^ selecteds first! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:17'!
initialize
	empregados := EmptyList  ofType: Empregado
! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/17/2012 19:30'!
listarEmpregados
	self empregados
		do: [ :empregado |
			Transcript
				cr;
				tab;
				show: empregado matricula;
				space;
				show: empregado nome;
				space;
				show: empregado salario ]! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/19/2012 16:30'!
nomesEmpregados
	| result |
	result := OrderedCollection new.
	empregados do: [:each| result addAll: each nomesEmpregados].
	^ result! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/20/2012 07:04'!
numeroEmpregados
	| result |
	result := 0.
	empregados do: [:each| result := result + each numeroEmpregados].
	^ result! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'!
printOn: aStream
	super printOn: aStream.
	aStream
		nextPutAll: ': ';
		nextPutAll: nome! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:34'!
recuperarEmpregadoMatricula: aSmallInteger
	^ crudManager getElementById: aSmallInteger! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:34'!
removerEmpregadoMatricula: aSmallInteger
	^ crudManager deleteElementById: aSmallInteger! !

!Divisao methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/19/2012 07:48'!
todosEmpregados
	| result |
	result := OrderedCollection new.
	empregados do: [:each| result addAll: each todosEmpregados].
	^ result! !

!Divisao methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/17/2012 19:30'!
empregados
	^ empregados! !

!Divisao methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/29/2012 11:23'!
gerente
	^ gerente! !

!Divisao methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/29/2012 11:23'!
gerente: anObject
	gerente := anObject! !

!Divisao methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/17/2012 19:30'!
nome
	^ nome! !

!Divisao methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/17/2012 19:30'!
nome: anObject
	nome := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Divisao class
	instanceVariableNames: ''!

!Divisao class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 16:37'!
idSelector
	^#nome! !

!Divisao class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/17/2012 19:30'!
nome: aString
	^ self new nome: aString! !

AdaptiveBase subclass: #Empregado
	instanceVariableNames: 'matricula nome salario'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Examples-Model'!

!Empregado methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/21/2012 08:10'!
acceptVisitor: aVisitor
	aVisitor visitEmpregado: self! !

!Empregado methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/20/2012 10:21'!
empregadosSalarioMaiorQue: aSmallInteger
	| result |
	result := OrderedCollection new.
	(self salario > aSmallInteger) ifTrue: [result add: self].
	^ result! !

!Empregado methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/19/2012 16:29'!
nomesEmpregados
	| result |
	result := OrderedCollection new.
	result add: self nome.
	^ result! !

!Empregado methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/20/2012 07:06'!
numeroEmpregados
	| result |
	result := 1.
	^ result! !

!Empregado methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'!
printOn: aStream
	super printOn: aStream.
	aStream
		nextPutAll: ': ';
		nextPutAll: nome! !

!Empregado methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/19/2012 07:49'!
todosEmpregados
	| result |
	result := OrderedCollection new.
	result add: self.
	^ result! !

!Empregado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/14/2012 07:31'!
matricula
	^ matricula! !

!Empregado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/14/2012 07:31'!
matricula: anObject
	matricula := anObject! !

!Empregado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/14/2012 07:26'!
nome
	^ nome! !

!Empregado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/14/2012 07:26'!
nome: anObject
	nome := anObject! !

!Empregado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/14/2012 07:26'!
salario
	^ salario! !

!Empregado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/14/2012 07:26'!
salario: anObject
	salario := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Empregado class
	instanceVariableNames: 'proximaMatricula'!

!Empregado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/30/2012 15:56'!
idSelector
	^ #matricula! !

!Empregado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/14/2012 07:56'!
initialize
	"
	self initialize
	"
	self reinicieMatriculas! !

!Empregado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/14/2012 07:32'!
matricula: anInteger nome: aString salario: aFloat
	^ self new
	      matricula: anInteger;
		nome: aString;
		salario: aFloat ! !

!Empregado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/14/2012 07:28'!
nome: aString salario: aFloat
	^ self new
		nome: aString;
		salario: aFloat ! !

!Empregado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/14/2012 07:37'!
proximaMatricula
	proximaMatricula := proximaMatricula + 1.
	^ proximaMatricula! !

!Empregado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/14/2012 07:55'!
reinicieMatriculas
	proximaMatricula := 0..! !

!Empregado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/14/2012 21:26'!
ultimaMatricula
	^ proximaMatricula! !

AdaptiveBase subclass: #Empresa
	instanceVariableNames: 'nome departamentos'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Examples-Model'!

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/21/2012 08:09'!
acceptVisitor: aVisitor
	aVisitor visitEmpresa: self! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
addDepartamento: anElement
		"Generated code"
		|toAdd|
		toAdd := self getDepartamentoByNome: (anElement perform: anElement class idSelector).
		toAdd ifNotNil: [:found|self error: found asString, 'already exists'].
		^ departamentos := departamentos add: anElement! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/24/2012 08:27'!
adicionarDepartamento: aDepartamento
	^ departamentos := crudManager addElement: aDepartamento! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
deleteDepartamentoByNome: anId
		"Generated code"
		|toDelete|
		toDelete := self getDepartamentoByNome: anId.
		^ departamentos := departamentos remove: toDelete! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:59'!
empregadoComMaiorSalario
		"Operation entry point generated code"
		| visitor |
		visitor := (Operation atSignature: #empregadoComMaiorSalario) createVisitor.
	visitor arguments: thisContext arguments.
		visitor visit: self.
		^ visitor result value! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:59'!
empregadosPorDepartamento
		"Operation entry point generated code"
		| visitor |
		visitor := (Operation atSignature: #empregadosPorDepartamento) createVisitor.
	visitor arguments: thisContext arguments.
		visitor visit: self.
		^ visitor result value! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:59'!
empregadosSalarioMaiorQue: anObject1
		"Operation entry point generated code"
		| visitor |
		visitor := (Operation atSignature: #empregadosSalarioMaiorQue:) createVisitor.
	visitor arguments: thisContext arguments.
		visitor visit: self.
		^ visitor result value! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 22:06'!
getDepartamentoByNome: anId
		"Generated code"
		|selecteds|
		selecteds := departamentos select: [:each| (each perform: #nome) = anId].
		selecteds ifEmpty: [^ nil].
			^ selecteds first! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:17'!
initialize
	departamentos := EmptyList ofType: Departamento..

	self
		addDepartamento: (Departamento nome: 'A');
		addDepartamento: (Departamento nome: 'B');
		addDepartamento: (Departamento nome: 'C').

	Empregado reinicieMatriculas.

	(self getDepartamentoByNome: 'A') gerente: (Empregado matricula: Empregado proximaMatricula nome: 'João' salario: 5000).
	(self getDepartamentoByNome: 'A')
		addEmpregado: (self getDepartamentoByNome: 'A') gerente;
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Maria' salario: 6000);
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Paulo' salario: 3000).

	(self getDepartamentoByNome: 'B') gerente: (Empregado matricula: Empregado proximaMatricula nome: 'Carla' salario: 7000).
	(self getDepartamentoByNome: 'B')
		addEmpregado: (self getDepartamentoByNome: 'B') gerente;
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Pedro' salario: 2000).

	(self getDepartamentoByNome: 'C') gerente: (Empregado matricula: Empregado proximaMatricula nome: 'Mateus' salario: 5000).
	(self getDepartamentoByNome: 'C')
		addEmpregado: (self getDepartamentoByNome: 'C') gerente.

	(self getDepartamentoByNome: 'A')
		addDivisao: (Divisao nome: 'D').
	(self getDepartamentoByNome: 'B')
		addDivisao: (Divisao nome: 'E');
		addDivisao: (Divisao nome: 'F').
	(self getDepartamentoByNome: 'C')
		addDivisao: (Divisao nome: 'G');
		addDivisao: (Divisao nome: 'H');
		addDivisao: (Divisao nome: 'I').

	((self getDepartamentoByNome: 'A') getDivisaoByNome: 'D') gerente: (Empregado matricula: Empregado proximaMatricula nome: 'Paulo' salario: 5200).
	((self getDepartamentoByNome: 'A') getDivisaoByNome: 'D')
		addEmpregado: ((self getDepartamentoByNome: 'A') getDivisaoByNome: 'D') gerente;
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Tatiana' salario: 6100);
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Joana' salario: 3500).

	((self getDepartamentoByNome: 'B') getDivisaoByNome: 'E')
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Diego' salario: 2200);
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Natacha' salario: 8100).
	((self getDepartamentoByNome: 'B') getDivisaoByNome: 'F')
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Carolina' salario: 7100).
	((self getDepartamentoByNome: 'B') getDivisaoByNome: 'E') gerente: ((self getDepartamentoByNome: 'B') getDivisaoByNome: 'E') empregados head.

	((self getDepartamentoByNome: 'C') getDivisaoByNome: 'G')
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Rodrigo' salario: 4100).
	((self getDepartamentoByNome: 'C') getDivisaoByNome: 'G') gerente: ((self getDepartamentoByNome: 'C') getDivisaoByNome: 'G') empregados head.

	((self getDepartamentoByNome: 'C') getDivisaoByNome: 'H')
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Pedro' salario: 2200);
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Raissa' salario: 8100).
	((self getDepartamentoByNome: 'C') getDivisaoByNome: 'H') gerente: ((self getDepartamentoByNome: 'C') getDivisaoByNome: 'H') empregados head.

	((self getDepartamentoByNome: 'C') getDivisaoByNome: 'I')
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Francisco' salario: 5200);
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Melissa' salario: 6100);
		addEmpregado: (Empregado matricula: Empregado proximaMatricula nome: 'Betània' salario: 3500).
	((self getDepartamentoByNome: 'C') getDivisaoByNome: 'I') gerente: ((self getDepartamentoByNome: 'C') getDivisaoByNome: 'I') empregados head.

		! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/16/2012 12:16'!
listarDepartamentos
	self departamentos
		do: [:departamento|
			Transcript
				space;
				show: departamento nome
				] ! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/19/2012 07:54'!
listarEmpregados
	| empregados |
	Transcript cr; show: 'Empregados:'.
	empregados := self todosEmpregados.
	empregados do: [:empregado|
		Transcript cr; tab; show: empregado matricula; space; show: empregado nome; space; show: empregado salario.
	]! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/20/2012 10:23'!
listarEmpregadosComSalariosAltos
	| empregados |
	Transcript cr; show: 'Empregados com salarios altos:'.
	empregados := self empregadosSalarioMaiorQue: 7000.
	empregados do: [:empregado|
		Transcript cr; tab; show: empregado matricula; space; show: empregado nome; space; show: empregado salario.
	]! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/16/2012 11:40'!
listarEmpregadosPorDepartamento
	self departamentos do: [:departamento|
		Transcript cr; show: departamento nome.
		departamento listarEmpregados
	]! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/19/2012 16:32'!
listarNomesEmpregados
	| nomes |
	Transcript cr; show: 'Nomes de empregados:'.
	nomes := self nomesEmpregados.
	nomes do: [:each|
		Transcript space; show: each
	]! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'!
listarNumeroEmpregados
	Transcript
		cr;
		show: 'Número de empregados: ';
		show: self numeroEmpregados asString! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:59'!
nomesDepartamentos
		"Operation entry point generated code"
		| visitor |
		visitor := (Operation atSignature: #nomesDepartamentos) createVisitor.
	visitor arguments: thisContext arguments.
		visitor visit: self.
		^ visitor result value! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:59'!
nomesEmpregados
		"Operation entry point generated code"
		| visitor |
		visitor := (Operation atSignature: #nomesEmpregados) createVisitor.
	visitor arguments: thisContext arguments.
		visitor visit: self.
		^ visitor result value! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:59'!
numeroEmpregados
		"Operation entry point generated code"
		| visitor |
		visitor := (Operation atSignature: #numeroEmpregados) createVisitor.
	visitor arguments: thisContext arguments.
		visitor visit: self.
		^ visitor result value! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'!
printOn: aStream
	super printOn: aStream.
	aStream
		nextPutAll: ': ';
		nextPutAll: nome! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:20'!
recuperarDepartamentoNome: aByteString
	^ crudManager getElementById: aByteString! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/18/2012 13:21'!
removerDepartamentoNome: aString
	^ crudManager deleteElementById: aString! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:59'!
somaSalariosEmpregados
		"Operation entry point generated code"
		| visitor |
		visitor := (Operation atSignature: #somaSalariosEmpregados) createVisitor.
	visitor arguments: thisContext arguments.
		visitor visit: self.
		^ visitor result value! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:59'!
todosEmpregados
		"Operation entry point generated code"
		| visitor |
		visitor := (Operation atSignature: #todosEmpregados) createVisitor.
	visitor arguments: thisContext arguments.
		visitor visit: self.
		^ visitor result value! !

!Empresa methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 12:59'!
todosEmpregados2
		"Operation entry point generated code"
		| visitor |
		visitor := (Operation atSignature: #todosEmpregados2) createVisitor.
	visitor arguments: thisContext arguments.
		visitor visit: self.
		^ visitor result value! !

!Empresa methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/16/2012 10:59'!
departamentos
	^ departamentos! !

!Empresa methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/16/2012 10:59'!
nome
	^ nome! !

!Empresa methodsFor: 'accessing' stamp: 'FranciscoAryMartins 6/16/2012 10:59'!
nome: anObject
	nome := anObject! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Empresa class
	instanceVariableNames: ''!

!Empresa class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 07:47'!
nome: aByteString
	^ self new
		nome: aByteString ! !

Empregado initialize!
Object subclass: #AplicacaoBlogPost
	instanceVariableNames: 'empresa'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'AdaptiveProgrammingBlogPost-Examples-UI'!

!AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 10:26'!
initialize
	empresa := Empresa nome: 'ABC Ltda.'.

	((Operation
		signature: #todosEmpregados
		result: [OrderedCollection new]
		from: Empresa
		bypassing: #gerente
		to: Empregado)
		wrapper: Empregado  with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				visitor result add: visited
			]
		]
		) compile.

	((Operation
		signature: #todosEmpregados2
		result: [Set new]
		from: Empresa
		to: Empregado)
		wrapper: Empregado  with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				visitor result add: visited
			]
		]
		) compile.

	((Operation
		signature: #nomesEmpregados
		result: [OrderedCollection new]
		from: Empresa
		bypassing: #gerente
		to: Empregado)
		wrapper: Empregado  with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				visitor result add: visited nome
			]]
		) compile.

	((Operation
		signature: #numeroEmpregados
		result: [Accumulator value: 0]
		from: Empresa
		bypassing: #gerente
		to: Empregado)
		wrapper: Empregado  with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				visitor result value: visitor result value + 1
			]]
		) compile.

	((Operation
		signature: #empregadosSalarioMaiorQue:
		result: [OrderedCollection new]
		from: Empresa
		bypassing: #gerente
		to: Empregado)
		wrapper: Empregado  with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				visited salario > visitor arguments first ifTrue: [visitor result add: visited]
			]]
		) compile.

	((Operation
		signature: #somaSalariosEmpregados
		result: [Accumulator value: 0]
		from: Empresa
		bypassing: #gerente
		to: Empregado)
		wrapper: Empregado  with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				visitor result value: visitor result value + visited salario
			]]
		) compile.

	((Operation
		signature: #empregadoComMaiorSalario
		result: [Accumulator value: nil]
		from: Empresa
		to: Empregado)
		wrapper: Empregado  with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				(visitor result value isNil or: [visited salario > visitor result value salario]) ifTrue: [visitor result: visited]
			]]
		) compile.

	((Operation
		signature: #nomesDepartamentos
		result: [OrderedCollection new]
		from: Empresa
		to: Departamento)
		wrapper: Departamento  with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				visitor result add: visited nome
			]	]
		) compile.

	((Operation
		signature: #empregadosPorDepartamento
		result: [Dictionary new]
		from: Empresa
		bypassing: #gerente
		to: Empregado)
		wrapper: Departamento  with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				visitor result at: visited put: nil.
				visitor result at: #empregados put: OrderedCollection new
			].
			wrapper suffix: [:visitor :visited|
				visitor result at: visited put: (visitor result at: #empregados)
			]
		];
		wrapper: Empregado with: [:wrapper|
			wrapper prefix: [:visitor :visited|
				(visitor result at: #empregados) add: visited
			]
		]
		) compile.! !

!AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/26/2012 14:39'!
listarEmpregadoComMaiorSalario
	| empregado |
	Transcript cr; show: 'Empregado com maior salário:'.
	empregado := empresa empregadoComMaiorSalario.
	Transcript tab; show: empregado matricula; space; show: empregado nome; space; show: empregado salario.! !

!AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/1/2012 20:32'!
listarEmpregados
	| empregados |
	Transcript cr; show: 'Empregados:'.
	empregados := empresa todosEmpregados2.
	(empregados sorted: [:emp1 :emp2| emp1 matricula < emp2 matricula]) do: [:empregado| 		Transcript cr; tab; show: empregado matricula; space; show: empregado nome; space; show: empregado salario. 	]! ! !AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'! listarEmpregadosComSalariosAltos 	| empregados salario | 	salario := 7000. 	Transcript 		cr; 		show: 'Empregados com salarios maiores que '; 		show: salario asString. 	empregados := empresa empregadosSalarioMaiorQue: salario. 	empregados 		do: [ :empregado |  			Transcript 				cr; 				tab; 				show: empregado matricula; 				space; 				show: empregado nome; 				space; 				show: empregado salario ]! ! !AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:59'! listarEmpregadosPorDepartamento 	| departamentos | 	Transcript 		cr; 		show: 'Empregados por departamento:'. 	departamentos := empresa empregadosPorDepartamento. 	departamentos 		keysAndValuesDo: [ :key :value |  			| departamento empregados | 			key = #empregados 				ifFalse: [  					departamento := key. 					empregados := value. 					Transcript 						cr; 						show: 'Departamento: '; 						show: departamento nome; 						show: ', gerente: '; 						show: departamento gerente nome. 					empregados 						do: [ :empregado |  							Transcript 								cr; 								tab; 								show: empregado matricula; 								space; 								show: empregado nome; 								space; 								show: empregado salario ] ] ]! ! !AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/14/2012 07:57'! listarEmpregadosdoDepartamento: dep 	Transcript 		cr; 		show: 'Empregados:'. 	dep empregados 		do: [ :empregado |  			Transcript 				cr; 				tab; 				show: empregado matricula; 				space; 				show: empregado nome; 				space; 				show: empregado salario ]! ! !AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/27/2012 20:33'! listarNomesDepartamentos 	| nomes | 	Transcript cr; show: 'Nomes dos departamentos: '. 	nomes := empresa nomesDepartamentos. 	nomes do: [:each| 		Transcript space; show: each 	]! ! !AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/25/2012 20:34'! listarNomesEmpregados 	| nomes | 	Transcript cr; show: 'Nomes de empregados:'. 	nomes := empresa nomesEmpregados. 	nomes do: [:each| 		Transcript space; show: each 	]! ! !AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'! listarNumeroEmpregados 	Transcript 		cr; 		show: 'Número de empregados: '; 		show: empresa numeroEmpregados asString! ! !AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'! listarSomaSalariosEmpregados 	Transcript 		cr; 		show: 'Soma dos salários dos empregados: '; 		show: empresa somaSalariosEmpregados asString! ! !AplicacaoBlogPost methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 6/29/2012 13:00'! run 	Transcript clear.	 	self listarEmpregados. 	self listarNomesEmpregados. 	self listarNumeroEmpregados. 	self listarEmpregadosComSalariosAltos. 	self listarSomaSalariosEmpregados. 	self listarEmpregadoComMaiorSalario. 	self listarNomesDepartamentos. 	self listarEmpregadosPorDepartamento! ! 
 Object subclass: #Clientes 	instanceVariableNames: 'clientes' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Clientes methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! addCliente: anElement 		"CRUD generated code" 		|toAdd| 		toAdd := self getClienteByNome: (anElement perform: anElement class idSelector). 		toAdd ifNotNil: [:found|(CannotAddElementAlreadyExists element: found) signal]. 		^ clientes := clientes add: anElement! ! !Clientes methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! deleteClienteByNome: anId 		"CRUD generated code" 		(self getClienteByNome: anId)  			ifNotNil: [:toDelete| ^ clientes := clientes remove: toDelete] 			ifNil: [(CannotDeleteElementNotExists elementId: anId) signal]! ! !Clientes methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! getClienteByNome: anId 		"CRUD generated code" 		|selecteds| 		selecteds := clientes select: [:each| (each perform: #nome) value = anId]. 		selecteds ifEmpty: [^ nil]. 			^ selecteds first! ! !Clientes methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:33'! initialize 	clientes := EmptyList ofType: Cliente.! ! !Clientes methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/4/2012 12:30'! clientes 	^ clientes! !  Error subclass: #VideoLocadoraError 	instanceVariableNames: '' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'!  VideoLocadoraError subclass: #VideoNaoEncontrado 	instanceVariableNames: 'codigo' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !VideoNaoEncontrado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/14/2012 09:37'! codigo 	^ codigo! ! !VideoNaoEncontrado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/14/2012 09:37'! codigo: anObject 	codigo := anObject! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! VideoNaoEncontrado class 	instanceVariableNames: ''! !VideoNaoEncontrado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 09:38'! codigo: anObject 	^ self new 		codigo anObject! !  VideoLocadoraError subclass: #ClienteNaoEncontrado 	instanceVariableNames: 'nome' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !ClienteNaoEncontrado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/13/2012 13:10'! nome 	^ nome! ! !ClienteNaoEncontrado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/13/2012 13:10'! nome: anObject 	nome := anObject! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! ClienteNaoEncontrado class 	instanceVariableNames: ''! !ClienteNaoEncontrado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/13/2012 23:15'! nome: aByteString  	^ self new 		nome value: aByteString! !  Object subclass: #Titulos 	instanceVariableNames: 'titulos' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Titulos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! addTitulo: anElement 		"CRUD generated code" 		|toAdd| 		toAdd := self getTituloByNome: (anElement perform: anElement class idSelector). 		toAdd ifNotNil: [:found|(CannotAddElementAlreadyExists element: found) signal]. 		^ titulos := titulos add: anElement! ! !Titulos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! deleteTituloByNome: anId 		"CRUD generated code" 		(self getTituloByNome: anId)  			ifNotNil: [:toDelete| ^ titulos := titulos remove: toDelete] 			ifNil: [(CannotDeleteElementNotExists elementId: anId) signal]! ! !Titulos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! getTituloByNome: anId 		"CRUD generated code" 		|selecteds| 		selecteds := titulos select: [:each| (each perform: #nome) value = anId]. 		selecteds ifEmpty: [^ nil]. 			^ selecteds first! ! !Titulos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:17'! initialize 	titulos := EmptyList ofType: Titulo.! ! !Titulos methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/4/2012 12:29'! titulos 	^ titulos! !  Object subclass: #Ator 	instanceVariableNames: 'nome' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Ator methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 11:57'! initialize 	nome := Terminal ofType: String! ! !Ator methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/8/2012 15:53'! nome 	^ nome! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Ator class 	instanceVariableNames: ''! !Ator class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 12:44'! idSelector 	^ #nome! ! !Ator class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:00'! nome: aByteString  	| instance | 	instance := self new. 	instance nome value: aByteString . 	^ instance! !  Object subclass: #Diretor 	instanceVariableNames: 'nome' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Diretor methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:01'! initialize 	nome := Terminal ofType: String! ! !Diretor methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/7/2012 13:01'! nome 	^ nome! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Diretor class 	instanceVariableNames: ''! !Diretor class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 12:43'! idSelector 	^ #nome! ! !Diretor class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:02'! nome: aByteString  	| instance | 	instance := self new. 	instance nome value: aByteString . 	^ instance! !  Object subclass: #Atores 	instanceVariableNames: 'atores' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Atores methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! addAtor: anElement 		"CRUD generated code" 		|toAdd| 		toAdd := self getAtorByNome: (anElement perform: anElement class idSelector). 		toAdd ifNotNil: [:found|(CannotAddElementAlreadyExists element: found) signal]. 		^ atores := atores add: anElement! ! !Atores methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! deleteAtorByNome: anId 		"CRUD generated code" 		(self getAtorByNome: anId)  			ifNotNil: [:toDelete| ^ atores := atores remove: toDelete] 			ifNil: [(CannotDeleteElementNotExists elementId: anId) signal]! ! !Atores methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! getAtorByNome: anId 		"CRUD generated code" 		|selecteds| 		selecteds := atores select: [:each| (each perform: #nome) value = anId]. 		selecteds ifEmpty: [^ nil]. 			^ selecteds first! ! !Atores methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:32'! initialize 	atores := EmptyList ofType: Ator.! ! !Atores methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/4/2012 12:30'! atores 	^ atores! !  Object subclass: #Titulo 	instanceVariableNames: 'nome preco diretor atores' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Titulo methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/8/2012 12:04'! atores 	^ atores! ! !Titulo methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/8/2012 10:22'! nome 	^ nome! ! !Titulo methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/8/2012 12:04'! preco 	^ preco! ! !Titulo methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/8/2012 12:03'! diretor 	^ diretor! ! !Titulo methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 13:52'! initialize 	atores := NonTerminal ofType: Atores. 	atores value: Atores new. 	diretor := NonTerminal ofType: Diretor. 	nome := Terminal ofType: String. 	preco := Terminal ofType: Float.! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Titulo class 	instanceVariableNames: ''! !Titulo class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/4/2012 12:43'! idSelector 	^ #nome! ! !Titulo class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 13:12'! nome: aByteString diretor: aDiretor preco: aFloat  	| instance | 	instance := self new. 	instance	nome value: aByteString . 	instance	diretor value: aDiretor . 	instance	preco value: aFloat. 		^ instance! !  Object subclass: #Emprestimos 	instanceVariableNames: 'emprestimos' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Emprestimos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! addEmprestimo: anElement 		"CRUD generated code" 		|toAdd| 		toAdd := self getEmprestimoByHash: (anElement perform: anElement class idSelector). 		toAdd ifNotNil: [:found|(CannotAddElementAlreadyExists element: found) signal]. 		^ emprestimos := emprestimos add: anElement! ! !Emprestimos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! deleteEmprestimoByHash: anId 		"CRUD generated code" 		(self getEmprestimoByHash: anId)  			ifNotNil: [:toDelete| ^ emprestimos := emprestimos remove: toDelete] 			ifNil: [(CannotDeleteElementNotExists elementId: anId) signal]! ! !Emprestimos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! getEmprestimoByHash: anId 		"CRUD generated code" 		|selecteds| 		selecteds := emprestimos select: [:each| (each perform: #hash) value = anId]. 		selecteds ifEmpty: [^ nil]. 			^ selecteds first! ! !Emprestimos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:17'! initialize 	emprestimos := EmptyList ofType: Emprestimo.! ! !Emprestimos methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/4/2012 12:29'! emprestimos 	^ emprestimos! !  VideoLocadoraError subclass: #DiretorNaoEncontrado 	instanceVariableNames: '' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'!  VideoLocadoraError subclass: #VideoJaEstaEmprestado 	instanceVariableNames: 'video' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !VideoJaEstaEmprestado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/11/2012 12:18'! video 	^ video! ! !VideoJaEstaEmprestado methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/11/2012 12:18'! video: anObject 	video := anObject! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! VideoJaEstaEmprestado class 	instanceVariableNames: ''! !VideoJaEstaEmprestado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/11/2012 12:19'! video: anObject 	^ self new 		video: anObject! !  Object subclass: #Videos 	instanceVariableNames: 'videos' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Videos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! addVideo: anElement 		"CRUD generated code" 		|toAdd| 		toAdd := self getVideoByCodigo: (anElement perform: anElement class idSelector). 		toAdd ifNotNil: [:found|(CannotAddElementAlreadyExists element: found) signal]. 		^ videos := videos add: anElement! ! !Videos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! deleteVideoByCodigo: anId 		"CRUD generated code" 		(self getVideoByCodigo: anId)  			ifNotNil: [:toDelete| ^ videos := videos remove: toDelete] 			ifNil: [(CannotDeleteElementNotExists elementId: anId) signal]! ! !Videos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! getVideoByCodigo: anId 		"CRUD generated code" 		|selecteds| 		selecteds := videos select: [:each| (each perform: #codigo) value = anId]. 		selecteds ifEmpty: [^ nil]. 			^ selecteds first! ! !Videos methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:17'! initialize 	videos := EmptyList ofType: Video.! ! !Videos methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/5/2012 12:17'! videos 	^ videos! !  Object subclass: #VideoLocadora 	instanceVariableNames: 'nome videos clientes emprestimos titulos diretores atores' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! adicionarAtorNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #adicionarAtorNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! adicionarClienteNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #adicionarClienteNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! adicionarDiretorNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #adicionarDiretorNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! adicionarEmprestimoClienteNome: anObject1 videoCodigo: anObject2 data: anObject3 prazo: anObject4  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #adicionarEmprestimoClienteNome:videoCodigo:data:prazo:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! adicionarTituloNome: anObject1 diretor: anObject2 atores: anObject3 preco: anObject4  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #adicionarTituloNome:diretor:atores:preco:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! adicionarVideoCodigo: anObject1 titulo: anObject2  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #adicionarVideoCodigo:titulo:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! devolverVideoCodigo: anObject1 data: anObject2  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #devolverVideoCodigo:data:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 19:29'! generate 		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #generate) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 15:10'! initialize 	nome := (Terminal ofType: String) value: 'ABC Vídeo Ltda.'. 	clientes := (NonTerminal ofType: Clientes) value: Clientes new. 	videos := (NonTerminal ofType: Videos) value: Videos new. 	emprestimos :=  (NonTerminal ofType: Emprestimos) value: Emprestimos new. 	titulos := (NonTerminal ofType: Titulos) value: Titulos new. 	diretores := (NonTerminal ofType: Diretores) value: Diretores new.. 	atores := (NonTerminal ofType: Atores) value: Atores new.! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! listarEstruturaObjetos 		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #listarEstruturaObjetos) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! obterAtorNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #obterAtorNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! obterClienteNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #obterClienteNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! obterDiretorNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #obterDiretorNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! obterEmprestimoVideoCodigo: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #obterEmprestimoVideoCodigo:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! obterTituloNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #obterTituloNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! obterVideoCodigo: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #obterVideoCodigo:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! removerClienteNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #removerClienteNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! removerDiretorNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #removerDiretorNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! removerTituloNome: anObject1  		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #removerTituloNome:) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! todosAtores 		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #todosAtores) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! todosClientes 		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #todosClientes) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! todosDiretores 		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #todosDiretores) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! todosEmprestimos 		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #todosEmprestimos) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! todosTitulos 		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #todosTitulos) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! todosVideos 		"Operation entry point generated code" 		| visitor | 		visitor := (Operation atSignature: #todosVideos) createVisitor. 	visitor arguments: thisContext arguments. 		visitor visit: self. 		^ visitor result value! ! !VideoLocadora methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/8/2012 15:50'! atores 	^ atores! ! !VideoLocadora methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/2/2012 18:22'! clientes 	^ clientes! ! !VideoLocadora methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/7/2012 12:42'! diretores 	^ diretores! ! !VideoLocadora methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/2/2012 18:22'! emprestimos 	^ emprestimos! ! !VideoLocadora methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/2/2012 18:22'! nome 	^ nome! ! !VideoLocadora methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/4/2012 12:26'! titulos 	^ titulos! ! !VideoLocadora methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/2/2012 18:22'! videos 	^ videos! !  VideoLocadoraError subclass: #EmprestimoNaoEncontrado 	instanceVariableNames: 'codigo' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !EmprestimoNaoEncontrado methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/13/2012 08:14'! codigo 	^ codigo! ! !EmprestimoNaoEncontrado methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/13/2012 08:09'! codigo: aSmallInteger  	codigo := aSmallInteger! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! EmprestimoNaoEncontrado class 	instanceVariableNames: ''! !EmprestimoNaoEncontrado class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/13/2012 08:08'! codigo: aSmallInteger  	^ self new 		codigo: aSmallInteger! !  Object subclass: #Video 	instanceVariableNames: 'codigo titulo' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Video methodsFor: 'comparing' stamp: 'FranciscoAryMartins 7/8/2012 19:55'! = anObject 	"Answer whether the receiver and anObject represent the same object." 	self == anObject 		ifTrue: [ ^ true ]. 	self class = anObject class 		ifFalse: [ ^ false ]. 	^ codigo = anObject codigo! ! !Video methodsFor: 'comparing' stamp: 'FranciscoAryMartins 7/8/2012 19:55'! hash 	"Answer an integer value that is related to the identity of the receiver." 	^ codigo hash! ! !Video methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/5/2012 12:16'! codigo 	^ codigo! ! !Video methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/5/2012 12:16'! codigo: anObject 	codigo := anObject! ! !Video methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/8/2012 17:21'! titulo 	^ titulo! ! !Video methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/8/2012 17:21'! titulo: anObject 	titulo := anObject! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Video class 	instanceVariableNames: ''! !Video class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/8/2012 17:21'! codigo: aSmallInteger titulo: aTitulo  	^ self new 		codigo: aSmallInteger ; 		titulo: aTitulo ! ! !Video class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/2/2012 18:23'! idSelector 	^ #codigo! !  Object subclass: #Emprestimo 	instanceVariableNames: 'data prazo video cliente' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Emprestimo methodsFor: 'comparing' stamp: 'FranciscoAryMartins 7/8/2012 19:54'! = anObject 	"Answer whether the receiver and anObject represent the same object." 	self == anObject 		ifTrue: [ ^ true ]. 	self class = anObject class 		ifFalse: [ ^ false ]. 	^ video = anObject video! ! !Emprestimo methodsFor: 'comparing' stamp: 'FranciscoAryMartins 7/8/2012 19:54'! hash 	"Answer an integer value that is related to the identity of the receiver." 	^ video hash! ! !Emprestimo methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/8/2012 19:04'! cliente 	^ cliente! ! !Emprestimo methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/2/2012 18:27'! data 	^ data! ! !Emprestimo methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/8/2012 19:04'! prazo 	^ prazo! ! !Emprestimo methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/2/2012 18:27'! video 	^ video! ! !Emprestimo methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/16/2012 18:21'! initialize 	video := NonTerminal ofType: Video. 	cliente  := NonTerminal ofType: Cliente. 	data  := Terminal ofType: Date. 	prazo  := Terminal ofType: Integer 	! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Emprestimo class 	instanceVariableNames: ''! !Emprestimo class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:07'! cliente: aCliente video: aVideo data: aDate prazo: aInteger  	| instance | 	instance := self new. 	instance	cliente value: aCliente. 	instance	video value: aVideo. 	instance	data value: aDate. 	instance	prazo value: aInteger. 	^ instance! ! !Emprestimo class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/2/2012 18:28'! idSelector 	^ #hash! !  Object subclass: #Diretores 	instanceVariableNames: 'diretores' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Diretores methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! addDiretor: anElement 		"CRUD generated code" 		|toAdd| 		toAdd := self getDiretorByNome: (anElement perform: anElement class idSelector). 		toAdd ifNotNil: [:found|(CannotAddElementAlreadyExists element: found) signal]. 		^ diretores := diretores add: anElement! ! !Diretores methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! deleteDiretorByNome: anId 		"CRUD generated code" 		(self getDiretorByNome: anId)  			ifNotNil: [:toDelete| ^ diretores := diretores remove: toDelete] 			ifNil: [(CannotDeleteElementNotExists elementId: anId) signal]! ! !Diretores methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/15/2012 08:16'! getDiretorByNome: anId 		"CRUD generated code" 		|selecteds| 		selecteds := diretores select: [:each| (each perform: #nome) value = anId]. 		selecteds ifEmpty: [^ nil]. 			^ selecteds first! ! !Diretores methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:17'! initialize 	diretores := EmptyList ofType: Diretor.! ! !Diretores methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/7/2012 12:35'! diretores 	^ diretores! !  Object subclass: #Cliente 	instanceVariableNames: 'nome' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model'! !Cliente methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/12/2012 10:50'! initialize 	nome := Terminal ofType: String! ! !Cliente methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/2/2012 18:29'! nome 	^ nome! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Cliente class 	instanceVariableNames: ''! !Cliente class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/2/2012 18:24'! idSelector 	^ #nome! ! !Cliente class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/12/2012 12:58'! nome: aByteString  	| instance | 	instance := self new. 	instance nome value: aByteString . 	^ instance! ! 
 Object subclass: #AplicacaoVideoLocadora 	instanceVariableNames: 'videoLocadora' 	classVariableNames: '' 	poolDictionaries: '' 	category: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-UI'! !AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/11/2012 07:38'! adicionarAtorNome: aByteString  	Transcript 		cr; 		show: 'Adicionando ator '; 		show: aByteString; 		show: '...'. 	[  	videoLocadora adicionarAtorNome: aByteString. 	Transcript 		cr; 		tab; 		show: 'Ator adicionado!!' ] 		on: Error 		do: [ :error |  			Transcript 				cr; 				tab; 				show: 'Ator ', error elementId, ' já existe!!' ]! ! !AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/13/2012 23:17'! adicionarClienteNome: aByteString 	Transcript 		cr; 		show: 'Adicionando cliente '; 		show: aByteString; 		show: '...'. 	[  	videoLocadora adicionarClienteNome: aByteString. 	Transcript 		cr; 		tab; 		show: 'Cliente adicionado!!' ] 	 	on: Error 		do: [ :error |  			Transcript 				cr; 				tab; 				show: 'Cliente ', aByteString, ' já existe!!' ]! ! !AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/11/2012 07:39'! adicionarDiretorNome: aByteString 	Transcript 		cr; 		show: 'Adicionando diretor '; 		show: aByteString; 		show: '...'. 	[  	videoLocadora adicionarDiretorNome: aByteString. 	Transcript 		cr; 		tab; 		show: 'Diretor adicionado!!' ] 		on: Error 		do: [ :error |  			Transcript 				cr; 				tab; 				show: 'Diretor ', error elementId, ' já existe' ]! ! !AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 08:49'! adicionarEmprestimoClienteNome: aByteString videoCodigo: aSmallInteger data: aByteString3 prazo: aSmallInteger4  	| aDate stream | 	Transcript cr; show: 'Adicionando empréstimo cliente: ' , aByteString , ' video: ' , aSmallInteger asString , ' data: ' , aByteString3 , ' prazo: ' , aSmallInteger4 asString. 	[[[[ 		stream := ReadStream on: aByteString3. 		aDate := Date readFrom: stream pattern:  'd/m/yyyy'.  		videoLocadora 		adicionarEmprestimoClienteNome: aByteString 		videoCodigo: aSmallInteger 		data: aDate 		prazo: aSmallInteger4. 		Transcript cr; tab; show: 'Adicionado' 	]  		on: ClienteNaoEncontrado do: [:error | Transcript cr; tab; tab; show: 'Cliente ' , error nome , ' não encontrado']]  		on: VideoNaoEncontrado do: [:error | Transcript cr; tab; tab; show: 'Vídeo ' , error codigo , ' não encontrado']] 		on: VideoJaEstaEmprestado  do: [:error | Transcript cr; tab; tab; show: 'Vídeo ' , error video codigo asString  , ' já está emprestado']]  		on: Error do: [:error | Transcript cr; tab; tab; show: error description]! ! !AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 13:07'! adicionarTituloNome: aByteString diretor: aByteString2 atores: aCollection preco: aFloat  	Transcript 		cr; 		show: 'Adicionando título '; 		show: aByteString; 		cr; tab; tab; 		show: 'diretor: '; 		show: aByteString2; 		cr; tab; tab; 		show: 'atores: '; 		show: aCollection asString; 		cr; tab; tab; 		show: 'preço: '; 		show: aFloat asString ; 		show: '...'. 	[  	videoLocadora adicionarTituloNome: aByteString diretor: aByteString2 atores: aCollection preco: aFloat. 	Transcript 		cr; 		tab; 		show: 'Título adicionado' ] value 	 	"	on: Error 		do: [ :error |  			Transcript 				cr; 				tab; 				show: error description ]"! ! !AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/8/2012 18:04'! adicionarVideoCodigo: aSmallInteger titulo: aByteString  	Transcript cr; show: 'Adicionando video codigo: '; show: aSmallInteger; space; show: 'titulo: '; show: aByteString; show: '...'. 	(videoLocadora obterTituloNome: aByteString) 		ifNil: [Transcript cr; tab; show: 'Titulo não existe'] 		ifNotNil: [:titulo |  			videoLocadora adicionarVideoCodigo: aSmallInteger titulo: titulo. 			Transcript cr; tab; show: 'Adicionado']! ! !AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 18:01'! compilarCRUDs 	Transcript cr; show: 'Compilando CRUDs...'. 	(PackageCRUDGenerator packageName: 'AdaptiveProgrammingBlogPost-Examples-VideoLocadora-Model') compile. 	Transcript cr; tab; show: 'Compilado!!'! ! !AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 9/14/2012 22:43'! compilarOperacoes 	Transcript cr; show: 'Compilando operações..'. 	(Operation 		signature: #listarEstruturaObjetos 		result: [ 			Identer new 			] 		from:  VideoLocadora 		prefix: [:visitor :visited|  | identer | 			Transcript space; show: visited asString. 			identer:= visitor result. 			identer ident 			]  		edgeSuffix: [:visitor :visited :label| |identer | 			identer := visitor result. 			Transcript cr; show: identer identation; show: label; show: ':' 			] 		suffix: [:visitor :visited| | identer | 			identer := visitor result. 			identer unident 			] 		) compile. 	((Operation 		signature: #adicionarClienteNome: 		  		from: VideoLocadora 		to: Clientes) 		 		wrapper: Clientes with: [:wrapper| 			wrapper prefix: [:visitor :clientes| |nomeCliente| 				nomeCliente :=  visitor arguments first. 				clientes addCliente: (Cliente nome: nomeCliente) 				]			 		]) compile.  	 	((Operation 		signature: #todosClientes 		result: [OrderedCollection new] 		from: VideoLocadora 		bypassing: #cliente  		to: Cliente) 		 		wrapper: Cliente with: [:wrapper| 			wrapper prefix: [:visitor :cliente| 				visitor result add: cliente 				]			 		]) compile.  	 	((Operation 		signature: #obterClienteNome: 		result: [Accumulator new] 		from: VideoLocadora 		to: Clientes) 		 		wrapper: Clientes with: [:wrapper| 			wrapper prefix: [:visitor :clientes| 				visitor result value: (clientes getClienteByNome: visitor arguments first) 				]			 		]) compile.  	 	((Operation 		signature: #removerClienteNome: 		 		from: VideoLocadora 		to: Clientes) 		 		wrapper: Clientes with: [:wrapper| 			wrapper prefix: [:visitor :clientes| 				clientes deleteClienteByNome: visitor arguments first 				]			 		]) compile.  	 	((Operation 		signature: #adicionarDiretorNome: 		  		from: VideoLocadora 		to: Diretores) 		 		wrapper: Diretores with: [:wrapper| 			wrapper prefix: [:visitor :diretores| 				diretores addDiretor: (Diretor nome: visitor arguments first) 				]			 		]) compile.  	((Operation 		signature: #todosDiretores 		result: [OrderedCollection new] 		from: VideoLocadora 		to: Diretor) 		 		wrapper: Diretor with: [:wrapper| 			wrapper prefix: [:visitor :diretor| 				visitor result add: diretor 				]			 		]) compile.  	 	((Operation 		signature: #obterDiretorNome: 		result: [Accumulator new] 		from: VideoLocadora 		to: Diretores) 		 		wrapper: Diretores with: [:wrapper| 			wrapper prefix: [:visitor :diretores| 				visitor result value: (diretores getDiretorByNome: visitor arguments first) 				]			 		]) compile.  	 	((Operation 		signature: #removerDiretorNome: 		 		from: VideoLocadora 		to: Diretores) 		 		wrapper: Diretores with: [:wrapper| 			wrapper prefix: [:visitor :diretores| 				diretores deleteDiretorByNome: visitor arguments first 				]			 		]) compile.  	 	((Operation 		signature: #adicionarTituloNome:diretor:atores:preco: 		result: [Dictionary new] 		from: VideoLocadora 		to: Titulos) 		 		wrapper: VideoLocadora with: [:wrapper| 			wrapper prefix: [:visitor :locadora| | diretor nomeDiretor|	 				nomeDiretor := visitor arguments second . 				(diretor := locadora obterDiretorNome: nomeDiretor) ifNil: [(DiretorNaoEncontrado nome: nomeDiretor) signal].. 				visitor result at: #diretor put: diretor 			]				 		]; 		wrapper: Titulos with: [:wrapper| 			wrapper prefix: [:visitor :titulos| |nome diretor preco nomesAtores titulo| 				nome := visitor arguments first. 				diretor := visitor result at: #diretor. 				nomesAtores := visitor arguments third. 				preco := visitor arguments fourth. 				titulo := Titulo nome: nome diretor: diretor preco: preco. 				nomesAtores do: [:nomeAtor| titulo atores value addAtor: (Ator nome: nomeAtor)]. 				titulos addTitulo: titulo 				]			 		]) compile.  	 	((Operation 		signature: #todosTitulos 		result: [OrderedCollection new] 		from: VideoLocadora 		to: Titulo) 		 		wrapper: Titulo with: [:wrapper| 			wrapper prefix: [:visitor :titulo| 				visitor result add: titulo 				]			 		]) compile.  	 	((Operation 		signature: #obterTituloNome: 		result: [Accumulator new] 		from: VideoLocadora 		to: Titulos) 		 		wrapper: Titulos with: [:wrapper| 			wrapper prefix: [:visitor :titulos| 				visitor result value: (titulos getTituloByNome: visitor arguments first) 				]			 		]) compile.  	 	((Operation 		signature: #adicionarAtorNome: 		  		from: VideoLocadora 		to: Atores) 		 		wrapper: Atores with: [:wrapper| 			wrapper prefix: [:visitor :atores| 				atores addAtor: (Ator nome: visitor arguments first) 				]			 		]) compile.  	 	((Operation 		signature: #todosAtores 		result: [OrderedCollection new] 		from: VideoLocadora 		to: Ator) 		 		wrapper: Ator with: [:wrapper| 			wrapper prefix: [:visitor :ator| 				visitor result add: ator 				]			 		]) compile.  	 	((Operation 		signature: #obterAtorNome: 		result: [Accumulator new] 		from: VideoLocadora 		to: Atores) 		 		wrapper: Atores with: [:wrapper| 			wrapper prefix: [:visitor :atores| 				visitor result value: (atores getAtorByNome: visitor arguments first) 				]			 		]) compile.  	 	((Operation 		signature: #removerTituloNome: 		 		from: VideoLocadora 		to: Titulos) 		 		wrapper: Titulos with: [:wrapper| 			wrapper prefix: [:visitor :titulos| 				titulos deleteTituloByNome: visitor arguments first 				]			 		]) compile.  	 	((Operation 		signature: #adicionarVideoCodigo:titulo: 		  		from: VideoLocadora 		to: Videos) 		 		wrapper: Videos with: [:wrapper| 			wrapper prefix: [:visitor :videos| 				videos addVideo: (Video codigo: visitor arguments first titulo: visitor arguments second) 				]			 		]) compile.  	 	((Operation 		signature: #todosVideos 		result: [OrderedCollection new] 		from: VideoLocadora 		to: Video) 		 		wrapper: Video with: [:wrapper| 			wrapper prefix: [:visitor :video| 				visitor result add: video 				]			 		]) compile.  	 	((Operation 		signature: #obterVideoCodigo: 		result: [Accumulator new] 		from: VideoLocadora 		to: Videos) 		 		wrapper: Videos with: [:wrapper| 			wrapper prefix: [:visitor :videos| 				visitor result value: (videos getVideoByCodigo: visitor arguments first) 				]			 		]) compile.  	 	((Operation 		signature: #adicionarEmprestimoClienteNome:videoCodigo:data:prazo: 		result: [Dictionary new] 		 		from: VideoLocadora 		to: Emprestimos) 		 		wrapper: VideoLocadora with: [:wrapper| 			wrapper prefix: [:visitor :locadoraDeVideo| |nomeCliente cliente codigoVideo video| 				nomeCliente := visitor arguments first.	 				(cliente := locadoraDeVideo obterClienteNome:  nomeCliente) ifNil: [(ClienteNaoEncontrado nome: nomeCliente) signal].  				visitor result at: #cliente put: cliente. 				 				codigoVideo := visitor arguments second. 				(video := locadoraDeVideo obterVideoCodigo: codigoVideo) ifNil: [(VideoNaoEncontrado codigo: codigoVideo) signal].  				visitor result at: #video put: video. 			]				 		]; 		 		wrapper: Emprestimos with: [:wrapper| 			wrapper prefix: [:visitor :emprestimos| | cliente video codigoVideo data prazo| 				codigoVideo := visitor arguments second. 				(emprestimos getEmprestimoByHash: codigoVideo) ifNotNil: [:emprestimo|(VideoJaEstaEmprestado video: emprestimo video) signal]. 				cliente := visitor result at: #cliente. 				video := visitor result at: #video. 				data := visitor arguments third. 				prazo := visitor arguments fourth. 				emprestimos addEmprestimo:  					(Emprestimo cliente: cliente video: video data: data prazo: prazo) 				]			 		]) compile.  	 	((Operation 		signature: #devolverVideoCodigo:data: 		result: [Dictionary new] 		from: VideoLocadora 		to: Emprestimos) 		 		wrapper: VideoLocadora with: [:wrapper| 			wrapper prefix: [:visitor :locadoraDeVideo| |  codigoVideo emprestimo|			 				codigoVideo := visitor arguments first. 				(emprestimo := locadoraDeVideo obterEmprestimoVideoCodigo: codigoVideo) ifNil: [(EmprestimoNaoEncontrado codigo: codigoVideo) signal].  				visitor result at: #emprestimo put: emprestimo. 			]				 		]; 		 		wrapper: Emprestimos with: [:wrapper| 			wrapper prefix: [:visitor :emprestimos| |emprestimo atraso prazo data multa preco|  				emprestimo := visitor result at: #emprestimo.  				prazo := emprestimo prazo value. 				data := visitor arguments second. 				atraso := (data - emprestimo data value) days - prazo. 				visitor result at: #atraso put: atraso. 				atraso > 0 ifTrue: [
					preco := emprestimo video value titulo value preco value.
					multa := atraso * preco.
					visitor result at: #multa put: multa.
					]..
				emprestimos deleteEmprestimoByHash: emprestimo video hash
				]
		]) compile.

	((Operation
		signature: #obterEmprestimoVideoCodigo:
		result: [Accumulator new]
		from: VideoLocadora
		to: Emprestimos)

		wrapper: Emprestimos with: [:wrapper|
			wrapper prefix: [:visitor :emprestimos|
				visitor result value: (emprestimos getEmprestimoByHash: visitor arguments first)
				]
		]) compile.

	((Operation
		signature: #todosEmprestimos
		result: [OrderedCollection new]
		from: VideoLocadora
		to: Emprestimo)

		wrapper: Emprestimo with: [:wrapper|
			wrapper prefix: [:visitor :emprestimo|
				visitor result add: emprestimo
				]
		]) compile.

	Transcript cr; tab; show: 'Compilado!!'! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 10:38'!
devolverVideoCodigo: aInteger data: aByteString
	| aEmprestimo aDate dateStream |
	Transcript cr; show: 'Devolvendo video: ', aInteger asString , ' data: ', aByteString .
	dateStream := ReadStream on: aByteString .
	aDate := Date readFrom: dateStream pattern: 'd/m/yyyy'.

	[
	     |atraso multa result|
		result := (videoLocadora devolverVideoCodigo: aInteger data: aDate).
		atraso :=  result at: #atraso.
		atraso > 0 ifTrue: [
			multa := result at: #multa.
			Transcript cr; tab; tab; show: 'Atraso: ',  atraso asString.
			Transcript cr; tab; tab; show: 'Multa ',  multa asString
			].
		Transcript cr; tab; show: 'Devolvido!!'
	]

		on: EmprestimoNaoEncontrado do: [:error| Transcript cr; tab; tab; show: 'Empréstimo '; space; show: error codigo asString; space; show: 'não encontrado']! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/13/2012 12:53'!
initialize
	videoLocadora := VideoLocadora new
		! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:26'!
listarAtores
	Transcript cr; show: 'Atores:'.
	videoLocadora todosAtores
		ifNotEmptyDo: [:atores | atores
				do: [:ator | Transcript cr; tab; show: ator nome value]]
		ifEmpty: [Transcript cr; tab; show: 'Não há atores']! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:59'!
listarClienteNome: aByteString
	Transcript
		cr;
		show: 'Obtendo cliente cujo nome é ';
		show: aByteString.
	(videoLocadora obterClienteNome: aByteString)
		ifNotNil: [ :cliente |
			Transcript
				cr;
				tab;
				show: 'Cliente:';
				space;
				show: cliente nome ]
		ifNil: [
			Transcript
				cr;
				tab;
				show: 'Cliente ';
				show: aByteString;
				show: ' não encontrado' ]! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/13/2012 12:39'!
listarClientes
	Transcript cr; show: 'Clientes:'.
	videoLocadora todosClientes
		ifNotEmptyDo: [:clientes | clientes
				do: [:cliente | Transcript cr; tab; show: cliente nome value]]
		ifEmpty: [Transcript cr; tab; show: 'Não há clientes']! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'!
listarComandos
	Transcript
		cr;
		show: 'Comandos:'.
	self class methods
		do: [ :method |
			(method selector = #initialize or: [ self class hasInstVarNamed: method selector ])
				ifFalse: [
					Transcript
						cr;
						tab;
						show: '#';
						show: method selector ] ]! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:59'!
listarDiretorNome: aByteString
	Transcript
		cr;
		show: 'Obtendo diretor cujo nome é ';
		show: aByteString.
	(videoLocadora obterDiretorNome: aByteString)
		ifNotNil: [ :diretor |
			Transcript
				cr;
				tab;
				show: 'Diretor:';
				space;
				show: diretor nome ]
		ifNil: [
			Transcript
				cr;
				tab;
				show: 'Diretor ';
				show: aByteString;
				show: ' não encontrado' ]! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 12:25'!
listarDiretores
	Transcript cr; show: 'Diretores:'.
	videoLocadora todosDiretores
		ifNotEmptyDo: [:diretores | diretores
				do: [:diretor | Transcript cr; tab; show: diretor nome value]]
		ifEmpty: [Transcript cr; tab; show: 'Não há diretores']! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/16/2012 17:42'!
listarEmprestimos
	Transcript cr; show: 'Empréstimos'.
	videoLocadora todosEmprestimos
		ifNotEmptyDo: [:emprestimos | emprestimos
				do: [:emprestimo |
					Transcript cr; tab;
						show: 'Vídeo:';
						space; show: emprestimo video value codigo;
						space; show: 'título:';
						space; show: emprestimo video value titulo nome;
						space; show: 'valor:';
						space; show: emprestimo video value titulo preco;
						space; show: 'cliente:';
						space; show: emprestimo cliente value nome value;
						space; show: 'data:';
						space; show: emprestimo data;
						space; show: 'prazo:';
						space; show: emprestimo prazo
				]]
		ifEmpty: [Transcript cr; tab; show: 'Não há empréstimos']! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 08:58'!
listarEstruturaObjetos
	Transcript cr; show: '------------------ Estrutura de objetos: início -----------------------------'.
	videoLocadora listarEstruturaObjetos.
	Transcript cr; show: '------------------ Estrutura de objetos: fim --------------------------------'.! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 15:47'!
listarNomeVideoLocadora
	Transcript cr; show: videoLocadora nome value.
	Transcript cr; show: '---------------------------------------------------------------'! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/8/2012 10:13'!
listarTituloNome: aByteString
	Transcript
		cr;
		show: 'Obtendo título cujo nome é ';
		show: aByteString.
	(videoLocadora obterTituloNome: aByteString)
		ifNotNil: [ :titulo |
			Transcript
				cr;
				tab;
				show: 'Título';
				space;
				show: titulo nome ]
		ifNil: [
			Transcript
				cr;
				tab;
				show: 'Título ';
				show: aByteString;
				show: ' não encontrado' ]! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 14:07'!
listarTitulos
	Transcript cr; show: 'Titulos'.
	videoLocadora todosTitulos
		ifNotEmptyDo: [:titulos | titulos
				do: [:titulo |
					Transcript cr; tab; show: titulo nome; cr; tab; tab; show: 'Diretor: '; space; show: titulo diretor value nome value.
					Transcript cr; tab; tab; show: 'Atores: '.
					titulo atores value atores
						do: [:ator | Transcript cr; tab; tab; tab; show: ator nome value]]]
		ifEmpty: [Transcript cr; tab; show: 'Não há títulos']! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/9/2012 13:13'!
listarTitulosDisponiveis
	self shouldBeImplemented.! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/14/2012 14:09'!
listarVideos
	Transcript cr; show: 'Videos:'.
	videoLocadora todosVideos
		ifNotEmptyDo: [:videos | videos
				do: [:video |
					Transcript cr; tab; show: video codigo; space; show: 'título '; space; show: video titulo nome value.]]
		ifEmpty: [Transcript cr; tab; show: 'Não há videos']! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'!
removerClienteNome: aByteString
	Transcript
		cr;
		show: 'Removendo ';
		show: aByteString.
	[
	videoLocadora removerClienteNome: aByteString.
	Transcript
		cr;
		tab;
		show: 'Removido' ]
		on: Error
		do: [ :error |
			Transcript
				cr;
				tab;
				show: error description ]! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/7/2012 13:58'!
removerDiretorNome: aByteString
	Transcript
		cr;
		show: 'Removendo ';
		show: aByteString.
	[
	videoLocadora removerDiretorNome: aByteString.
	Transcript
		cr;
		tab;
		show: 'Removido' ]
		on: Error
		do: [ :error |
			Transcript
				cr;
				tab;
				show: error description ]! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/11/2012 09:30'!
removerTituloNome: aByteString
	Transcript
		cr;
		show: 'Removendo ';
		show: aByteString;
		show: '...'.
	[
	videoLocadora removerTituloNome: aByteString.
	Transcript
		cr;
		tab;
		show: 'Removido!!' ]
		on: Error
		do: [ :error |
			Transcript
				cr;
				tab;
				show: 'Título ', error elementId, ' não existe!!' ]! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/8/2012 19:33'!
validarCliente: aCliente video: aVideo data: aDate
	aCliente ifNil: [self error: 'Cliente não existe'].
	aVideo ifNil: [self error: 'Vídeo não existe'].
	aDate ifNil: [self error:  'Data inválida'].! !

!AplicacaoVideoLocadora methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/9/2012 12:56'!
validarEmprestimo: anEmprestimo data: aDate
	anEmprestimo ifNil: [self error: 'Cliente não existe'].
	aDate ifNil: [self error:  'Data inválida'].! !

!AplicacaoVideoLocadora methodsFor: 'accessing' stamp: 'FranciscoAryMartins 7/2/2012 18:21'!
videoLocadora
	^ videoLocadora! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

AplicacaoVideoLocadora class
	instanceVariableNames: ''!

!AplicacaoVideoLocadora class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 08:53'!
exemplo
	Transcript clear.
	AplicacaoVideoLocadora new
		listarNomeVideoLocadora;
		listarComandos ;
		compilarCRUDs ;
		compilarOperacoes ;
		listarEstruturaObjetos;
		adicionarDiretorNome: 'Steven Spielberg';
		listarDiretores;
		adicionarAtorNome: 'Jeremy Irvine';
		adicionarAtorNome: 'Emily Watson';
		adicionarAtorNome: 'David Thewlis';
		adicionarAtorNome: 'Jamie Bell';
		adicionarAtorNome: 'Andy Serkis';
		adicionarAtorNome: 'Daniel Craig';
		adicionarAtorNome: 'Tom Hanks';
		adicionarAtorNome: 'Toby Meuli';
		listarAtores;
		adicionarTituloNome: 'War Horse (2011)' diretor: 'Steven Spielberg' atores: #('Jeremy Irvine' 'Emily Watson' 'David Thewlis') preco: 4.00;
		adicionarTituloNome: 'The Adventures of Tintin' diretor: 'Steven Spielberg' atores: #('Jamie Bell' 'Andy Serkis' 'Daniel Craig') preco: 4.00;
		adicionarTituloNome: 'A Timeless Call' diretor: 'Steven Spielberg' atores: #('Tom Hanks' 'Toby Meuli') preco: 4.00;
		listarTitulos;
		listarTituloNome: 'The Adventures of Tintin';
		removerTituloNome: 'The Adventures of Tintin';
		removerTituloNome: 'The Adventures of Tintin';
		listarTituloNome: 'The Adventures of Tintin';
		adicionarVideoCodigo: 1 titulo: 'War Horse (2011)';
		adicionarVideoCodigo: 2 titulo: 'War Horse (2011)';
		adicionarVideoCodigo: 3 titulo: 'War Horse (2011)';
		adicionarVideoCodigo: 4 titulo: 'The Adventures of Tintin';
		adicionarVideoCodigo: 5 titulo: 'The Adventures of Tintin';
		adicionarVideoCodigo: 6 titulo: 'A Timeless Call';
		listarVideos;
		adicionarClienteNome: 'João';
		adicionarClienteNome: 'Pedro';
		adicionarClienteNome: 'Carlos';
		listarClientes;
		listarEmprestimos;
		"listarTitulosDisponiveis;"
		adicionarEmprestimoClienteNome: 'João' videoCodigo: 2 data: '8/07/2012' prazo: 3;
		adicionarEmprestimoClienteNome: 'Pedro' videoCodigo: 2 data: '9/7/2012' prazo: 2;
		listarClientes;
		listarEmprestimos;
		devolverVideoCodigo: 2 data: '19/7/2012';
		listarEmprestimos;
		adicionarEmprestimoClienteNome: 'Pedro' videoCodigo: 2 data: '19/7/2012' prazo: 2;
		listarEmprestimos;
		listarEstruturaObjetos .
	Transcript cr; show: '----------------------- F I M ---------------------------------'

! !

!AplicacaoVideoLocadora class methodsFor: 'as yet unclassified' stamp: 'FranciscoAryMartins 7/15/2012 08:49'!
exemplo2
	Transcript clear.
	Transcript cr; show: '------- Dicionário de c lasses----------------------'.
	AplicacaoVideoLocadora new
		compilarCRUDs;
		compilarOperacoes;
		listarNomeVideoLocadora;
		listarEstruturaObjetos.
	Transcript cr; show: '----------------------- F I M ---------------------------------'
! !

No próximo post vamos desenvolver a criação de um grafo para representar a estrutura de classes que poderá ser usado para obter os caminhos associados a cada operação.

Continua na parte 12.

Anúncios

2 comentários

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair / Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair / Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair / Alterar )

Foto do Google+

Você está comentando utilizando sua conta Google+. Sair / Alterar )

Conectando a %s