Wiki

Changes between Version 7 and Version 8 of Classes

Show
Ignore:
Timestamp:
02/19/09 00:31:41 (15 years ago)
Author:
Chuck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Classes

    v7 v8  
    66=== Class Grammar === 
    77{{{ 
    8 class <className>   
     8class <ClassName>   
    99    [is <AccessModifiers>] 
    1010    [has <Attributes>] 
     11    [where <GenericParam> must be <GenericConstraints>] 
    1112    [inherits <BaseClassName> ] 
    1213    [implements <InterfaceName> [, <InterfaceName>]...] 
     
    3637    [is <AccessModifiers>] 
    3738    [has <Attributes>] 
     39    [where <GenericParam> must be <GenericConstraints>] 
    3840    [inherits <BaseInterfaceName> [, <BaseInterfaceName>]... ] 
    3941    [<DocString>] 
     
    224226        return 'Herbivorous Cud Chewing' 
    225227      
    226     def nHooves as String 
    227         return 'four' 
     228    def numHooves as int 
     229        return 4 
    228230   
    229231 
     
    264266            pass 
    265267 
    266     def age( byNYears as int) 
     268    def age(byNYears as int) 
    267269        _age += byNYears 
    268270        if _age > _lifeSpan 
    269271            _isAlive = false 
    270272 
    271     def gainWgt( wgt as int) 
     273    def gainWgt(wgt as int) 
    272274        .liveWeight += wgt 
    273275 
    274276    def toString as String is new 
    275         return 'Sheep:age=[_age], wgt=[.liveWeight], living=[_isAlive]' 
     277        return 'Sheep:age=[_age], weight=[.liveWeight], living=[_isAlive]' 
    276278                 
    277279    def main is shared 
    278280        s = Sheep() 
    279         print 's=[s.toString]' 
     281        print 's=[s]' 
    280282        s.age(1) 
    281283