View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Dino M1

Object subclass: #Family
	instanceVariableNames: 'familyName mother father children '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'cs2340'!

!Family methodsFor: 'Initializing' stamp: 'Dino 9/4/2002 11:07'!
addChild: aPerson

		children isNil
			ifTrue: [children _ OrderedCollection new. 
					 children add: aPerson]
			ifFalse: [children add: aPerson].! !

!Family methodsFor: 'Initializing' stamp: 'Dino 9/3/2002 17:53'!
addFather: aPerson

	father _ aPerson.
	! !

!Family methodsFor: 'Initializing' stamp: 'Dino 9/4/2002 13:56'!
addMother: aPerson

	mother _ aPerson! !

!Family methodsFor: 'Initializing' stamp: 'Dino 9/4/2002 10:29'!
father

	^ father! !

!Family methodsFor: 'Initializing' stamp: 'Dino 9/4/2002 10:21'!
initialize
	
	children _ SortedCollection new.! !

!Family methodsFor: 'Initializing' stamp: 'Dino 9/4/2002 11:08'!
kids

	^children.! !

!Family methodsFor: 'Initializing' stamp: 'Dino 9/4/2002 10:29'!
mother

	^ mother! !
!Family methodsFor: 'Initializing' stamp: 'Dino 9/3/2002 17:19'!
new

	^ super new initialize! !

Object subclass: #Person
	instanceVariableNames: 'fName lName mInitial gender alias bDate birthLocation dDate deathLocation otherInfo familyMembers parentFamily anivDate pen p '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'cs2340'!

!Person methodsFor: 'Marriage-Relations' stamp: 'Dino 9/4/2002 18:24'!
hasChild: aPerson with: aPartner
		"Adds child to the family."


	familyMembers addChild: aPerson.
	aPerson parents: familyMembers! !

!Person methodsFor: 'Marriage-Relations' stamp: 'Dino 9/4/2002 13:59'!
married: aPerson on: aDate
		"Adds the spouse to the person."


	familyMembers _ Family new.
	familyMembers addFather: self.
	familyMembers addMother: aPerson.
	(familyMembers mother) initFamily: familyMembers.
	anivDate _ aDate.	! !


!Person methodsFor: 'Family-Relationships' stamp: 'Dino 9/4/2002 21:48'!
father

	^ parentFamily father.! !

!Person methodsFor: 'Family-Relationships' stamp: 'Dino 9/4/2002 21:45'!
hasFather: aPerson

		"Adds the persons father."

	
	parentFamily isNil
	ifTrue:[
		parentFamily _ Family new.
		parentFamily addFather: aPerson.]
	ifFalse:[
		parentFamily addFather: aPerson.]! !

!Person methodsFor: 'Family-Relationships' stamp: 'Dino 9/4/2002 21:46'!
hasMother: aPerson
		"Add the persons mother."

	parentFamily isNil
	ifTrue:[
		parentFamily _ Family new.
		parentFamily addMother: aPerson.]
	ifFalse:[ parentFamily addMother: aPerson.]! !

!Person methodsFor: 'Family-Relationships' stamp: 'Dino 9/4/2002 21:47'!
hasSibling: aPerson
		"Sets all the siblings for the person."


	parentFamily isNil
	ifTrue:[
		parentFamily _ Family new.
		parentFamily addChild: aPerson.]"Person's sibling is the family's child!!"
	ifFalse:[
		parentFamily addChild: aPerson.]! !

!Person methodsFor: 'Family-Relationships' stamp: 'Dino 9/4/2002 21:48'!
mother

	^ parentFamily mother.! !


!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:19'!
alias

		"Returns the value of alias."


	^ alias.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:29'!
alias: aString
		"Sets the value of the instance variable alias."


	alias add: aString.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:20'!
bDay
		"Returns the birth day of the person."


	^ bDate.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:20'!
born: aDate location: aString
		
	"Sets the persons birth date and location."


	bDate _ aDate.
	birthLocation _ aString.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:20'!
died: aDate location: aString
		"Sets the persons date of death and location."


	dDate _ aDate.
	deathLocation _ aString.
 ! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 17:23'!
family
		"Returns the Family object representing the persons family."
	
	^ familyMembers.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:27'!
gender: aString
		
	"Sets the gender."


		
	gender _ aString asLowercase.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:20'!
givenName
		"Returns the value of fName."

	^ fName.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:20'!
givenName: aString

		"Sets the value of the name instance variable."

	fName _ aString.	! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 17:25'!
hasFamily
		"Initializes the Family class."


	(familyMembers isNil) ifTrue: [familyMembers _ Family new].! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:28'!
isFemale
		"returns a boolean - self explanatory"


	^ (gender = 'female').! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:27'!
isMale

		"Returns a boolean - self explanatory."


	^(gender = 'male').! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:28'!
mName

		"Returns the value of mInitial."


	^ mInitial.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:28'!
mName: aString
		"Sets the value of the instance variable mInitial."


	mInitial _ aString. ! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/4/2002 17:33'!
parents

	^parentFamily! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/4/2002 17:33'!
parents: aFamily

	parentFamily _ aFamily

	! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/4/2002 10:17'!
record: aString as: anotherString

		"Records other data on the person such as SSN."

	otherInfo add: aString, ': ', anotherString.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 8/30/2002 15:18'!
surName
		"Returns the value of lName."

	^lName.! !

!Person methodsFor: 'Initialization' stamp: 'Dino 9/3/2002 18:29'!
surName: aString

		"Sets the value of the instance variable lName."


	lName _ aString.! !


!Person methodsFor: 'Displaying' stamp: 'Dino 9/3/2002 18:41'!
clearWorld

	(Form extent: 600@ 800)fillWhite display.! !

!Person methodsFor: 'Displaying' stamp: 'Dino 9/4/2002 10:25'!
draw

	| displayName |
	displayName _ (self givenName) asDisplayText.
	displayName foregroundColor:(Color black)
				 backgroundColor:(Color white).
	displayName displayAt:(pen location).! !

!Person methodsFor: 'Displaying' stamp: 'Dino 9/4/2002 21:37'!
drawDad: aPerson

	| displayName n|
	p _ (pen location x).
	aPerson givenName isNil ifTrue: [ n_ 'Unnamed']
		ifFalse: [ n _ aPerson givenName ].
	displayName _ (n, '           - married to - ') asDisplayText.
	displayName foregroundColor:(Color black)
				 backgroundColor:(Color white).
	displayName displayAt: (pen location).! !

!Person methodsFor: 'Displaying' stamp: 'Dino 9/4/2002 18:01'!
drawFam: aFamily


	self drawDad: aFamily father.
	self drawMom: aFamily mother.
	self drawKids: aFamily kids! !

!Person methodsFor: 'Displaying' stamp: 'Dino 9/4/2002 21:56'!
drawFamily: aFamily
	
	aFamily isNil 
	ifFalse: [
		(aFamily father parents) isNil
		ifTrue:[
			(aFamily mother parents) isNil 
			ifTrue:[
				self drawDad: aFamily father.
				self drawMom: aFamily mother.
				self drawKids: aFamily kids]	
		    ifFalse:[
				self drawFam: (aFamily mother) parents]]
		ifFalse:[
				self drawFam:(aFamily father) parents]].! !

!Person methodsFor: 'Displaying' stamp: 'Dino 9/4/2002 21:33'!
drawKids: aCollection

	| kid i n |
	
	aCollection isNil
ifFalse: [
	i _ aCollection size.
	self drawKidsHelper.
		1 to: i do: [ :index | 
				(((aCollection at: index) family) isNil) 
				ifFalse: [self drawFam: ((aCollection at: index) family)]
				ifTrue: [
				(aCollection at: index)givenName isNil
		      		 ifTrue: [n _ 'Unnamed']
					 ifFalse: [n _(aCollection at: index)givenName].
				kid _ n asDisplayText.
				kid foregroundColor:(Color black)
					backgroundColor:(Color white).
				kid displayAt: (pen location).
				pen place: (p+30)@((pen location y) + 15).]].
				pen place:(p)@(pen location y)].! !

!Person methodsFor: 'Displaying' stamp: 'Dino 9/4/2002 21:28'!
drawKidsHelper

	| displayString |

	pen place: (p)@((pen location y)+15).
	displayString _ 'Kids: '.
	displayString displayAt:(pen location).
	pen place: ((pen location x)+30)@(pen location y).	! !

!Person methodsFor: 'Displaying' stamp: 'Dino 9/4/2002 21:36'!
drawMom: aPerson

	| dName n |
	aPerson isNil
		ifFalse: [ aPerson givenName isNil ifTrue:[n_'Unnamed']
										   ifFalse:[n_aPerson givenName].
		dName _ n asDisplayText.
		dName foregroundColor:(Color black)
			    backgroundColor:(Color white).
		pen place: ((pen location x)+ 200) @ (pen location y).
		dName displayAt: (pen location). ].! !

!Person methodsFor: 'Displaying' stamp: 'Dino 9/4/2002 17:38'!
visualize


	self initPen.
	self clearWorld.
	familyMembers isNil
		ifTrue: [self drawFamily: parentFamily]
		ifFalse: [self drawFamily: (self family)]
	
! !


!Person methodsFor: 'Init' stamp: 'Dino 9/4/2002 10:42'!
initAlias

	alias _ OrderedCollection new! !

!Person methodsFor: 'Init' stamp: 'Dino 9/4/2002 10:17'!
initFamily

	familyMembers _ Family new! !

!Person methodsFor: 'Init' stamp: 'Dino 9/4/2002 13:58'!
initFamily: aFamily
	
	familyMembers _ aFamily! !

!Person methodsFor: 'Init' stamp: 'Dino 9/4/2002 10:42'!
initOtherInfo

	otherInfo _ OrderedCollection new! !

!Person methodsFor: 'Init' stamp: 'Dino 9/4/2002 14:20'!
initPen

	pen _ Pen new.
	pen place: 200@300.! !
Object subclass: #Picture
	instanceVariableNames: 'size pen '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'cs2340'!

!Picture methodsFor: 'displaying' stamp: 'Dino 9/2/2002 16:28'!
display: aPerson

	| relations i j |
	self initialize: aPerson.
	relations _ (aPerson family).
	i _1. j _1.
	[i < (relations width)] 
	whileTrue:[
			[relations at: i at: j isNil]
			whileFalse: [
				self display: (relations at: i at: j).
				j _ j+1.].
	i _ i+1.
	j _1.].
		
				
			
	
	! !

!Picture methodsFor: 'displaying' stamp: 'Dino 9/2/2002 15:29'!
draw: aPerson
	| displayName |
	((aPerson givenName) isNil) ifTrue:[( aPerson givenName:'Unnamed')].
	displayName _ (aPerson givenName) asDisplayText.
	displayName foregroundColor: (Color black)
				 backgroundColor: (Color white).
	displayName displayAt: (pen location).! !

!Picture methodsFor: 'displaying' stamp: 'Dino 9/2/2002 16:27'!
initialize: aPerson
	
		pen _ Pen new.
		pen place: 50@50.
		size _ 20.
		self draw: aPerson.! !



Link to this Page