2017-10-31 23:09:36 -04:00
|
|
|
const Cow = Class( 'Cow',
|
2012-05-05 14:09:27 -04:00
|
|
|
{
|
|
|
|
'const LEGS': 4,
|
|
|
|
|
|
|
|
'private static _number': 0,
|
|
|
|
|
2017-10-31 23:09:36 -04:00
|
|
|
constructor()
|
2012-05-05 14:09:27 -04:00
|
|
|
{
|
|
|
|
// __self refers to the class associated with this instance
|
2017-10-31 23:09:36 -04:00
|
|
|
this.__self.$( '_number' ) = this.__self.$( '_number' ) + 1;
|
2012-05-05 14:09:27 -04:00
|
|
|
},
|
|
|
|
|
2017-10-31 23:09:36 -04:00
|
|
|
'public static create'()
|
2012-05-05 14:09:27 -04:00
|
|
|
{
|
|
|
|
return Cow();
|
|
|
|
},
|
|
|
|
|
2017-10-31 23:09:36 -04:00
|
|
|
'public static getNumber'()
|
2012-05-05 14:09:27 -04:00
|
|
|
{
|
|
|
|
return this.__self.$( '_number' );
|
|
|
|
},
|
|
|
|
} );
|
|
|
|
|
|
|
|
Cow.$( 'LEGS' ); // 4
|
|
|
|
Cow.getNumber(); // 0
|
|
|
|
Cow.create();
|
|
|
|
Cow.getNumber(); // 1
|