'From Squeak3.0 of 4 February 2001 [latest update: #3545] on 16 December 2001 at 2:58:56 am'! Magnitude subclass: #Rank instanceVariableNames: 'myRank ' classVariableNames: 'AllRanks ' poolDictionaries: '' category: 'New Classes'! !Rank methodsFor: 'as yet unclassified' stamp: 'SMC 12/15/2001 02:57'! < aRank "Is self's rank less than aRank's?" | a b | a := (AllRanks indexOf: (self rank)) . b := (AllRanks indexOf: (aRank rank)) . ^ a < b! ! !Rank methodsFor: 'as yet unclassified' stamp: 'SMC 12/15/2001 02:56'! = aRank "Test two Rank instances for equality" | a b | a := (AllRanks indexOf: (self rank)) . b := (AllRanks indexOf: (aRank rank)) . ^ a = b! ! !Rank methodsFor: 'as yet unclassified' stamp: 'SMC 12/15/2001 02:53'! promote "Bump up one rank, if possible" | i | i := AllRanks indexOf: myRank. i := (i + 1) min: (AllRanks size). myRank := AllRanks at: i. ^self rank! ! !Rank methodsFor: 'as yet unclassified' stamp: 'SMC 12/15/2001 02:56'! rank "Display current rank" ^myRank! ! !Rank methodsFor: 'as yet unclassified' stamp: 'SMC 12/15/2001 02:58'! setRank: newRank "Set rank, if valid." (AllRanks includes: newRank) ifTrue: [ myRank := newRank ] ifFalse: [ self error: 'Illegal Rank'] . ^myRank! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Rank class instanceVariableNames: ''! !Rank class methodsFor: 'as yet unclassified' stamp: 'SMC 12/15/2001 02:58'! initialize "Initialize the set of possible ranks" AllRanks := #('Private' 'Corporal' 'Sergeant' 'Lieutenant' 'Captain' 'Major' 'Colonel' 'General')! ! Rank initialize!