Advertisement
Guest User

Untitled

a guest
Dec 12th, 2010
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.05 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Ohi</title>
  4.         <script>
  5.         test = { "People": { }, 'addPerson': function ( sName ) { this.People[ sName ] = new Person( sName ); } }
  6.  
  7.  
  8.   test.addPerson( 'Fred' );
  9.  
  10.  
  11. function Person( sName )
  12. {
  13.       this.sName = sName;
  14.  
  15.       this.Hats = [];
  16.       var oPar = this;
  17.       this.Hats[ "Red" ] = new Hat( oPar, "red" );
  18.       this.Hats[ "Yellow" ] = new Hat( oPar, "yellow" );
  19.  
  20.  
  21. }
  22.        
  23.        
  24. function Hat( oParent, sColor )
  25. {
  26.      this.parent = oParent;
  27.  
  28.       this.sColor = sColor;
  29.  
  30.      this.changeColor = function( sNewColor )
  31.        {
  32.          this.sColor = sNewColor;
  33.          return true;
  34.          
  35.        }
  36.        
  37.      this.OwnerName = function ( )
  38.        {
  39.          return this.parent.sName;
  40.        
  41.        }
  42.        
  43.        
  44.        }
  45.      
  46.        
  47.   console.log( test.People[ "Fred" ] );
  48.   console.log( test.People[ "Fred" ].Hats );
  49.   console.log( test.People[ "Fred" ].Hats.length );
  50.         </script>
  51.     </head>
  52.     <body>
  53.         Ohi
  54.         </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement