Count subclass: #DivisorCount
	instanceVariableNames: 'oddCount evenCount '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Counts'


DivisorCount methodsFor: 'counting'

decrement

	"I increment by one and if I am even, evenCount increments by 1 and if I am odd, 	oddCount increments by 1."

	value := value -1.
	self changed: #value.
	(value\2) == 1
		ifTrue: [oddCount decrement]
		ifFalse: [evenCount decrement]

increment
	"I increment by one and if I am even, evenCount increments by 1 and if I am odd, 	oddCount increments by 1."

	value := value + 1.
	self changed: #value.
	(value\2) == 1
		ifTrue: [oddCount increment]
		ifFalse: [evenCount increment]

reset
	"resets itself and resets oddCount and evenCount"

	self value: 0.
	oddCount reset.
	evenCount reset

reset2
	"resets Master value"	
	self value: 0

DivisorCount methodsFor: 'connections'

connectToEvenCount: anEvenCount 
	"connects to the EvenCount variable defined in the main program"

	evenCount := anEvenCount

connectToOddCount: anOddCount 
"connects to the EvenCount variable defined in the main program"

	oddCount := anOddCount

DivisorCount methodsFor: 'initialize release'

initialize
	"initializes the MasterCount variable to 0 and calls reset2"
	resetValue := 0.
	self reset2

DivisorCount class methodsFor: 'instance creation'

new
	| MasterCount OddCount EvenCount |
	MasterCount := super new initialize.
 	OddCount := IntegerCount new. 
	EvenCount := IntegerCount new.
	MasterCount connectToOddCount: OddCount.
	MasterCount connectToEvenCount: EvenCount.
	CountViewContainer new openOn: MasterCount labeled: 'Master'.
	SlaveViewContainer new openOn: OddCount labeled: 'Odd'.
	SlaveViewContainer new openOn: EvenCount labeled: 'Even'