File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var Westeros;
44 function Wall ( ) {
55 this . height = 0 ;
66 if ( Wall . _instance )
7- throw new Error ( "This is a singleton, use getInstance to get an instance" ) ;
7+ return Wall . _instance ;
88 Wall . _instance = this ;
99 }
1010 Wall . prototype . setHeight = function ( height ) {
@@ -33,3 +33,6 @@ var wall2 = Westeros.Wall.getInstance();
3333wall2 . getStatus ( ) ;
3434var wall3 = new Westeros . Wall ( ) ;
3535wall3 . getStatus ( ) ;
36+ wall3 . setHeight ( 20 ) ;
37+ var wall4 = new Westeros . Wall ( ) ;
38+ wall4 . getStatus ( ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module Westeros
66 private height :number = 0 ;
77 constructor ( ) {
88 if ( Wall . _instance )
9- throw new Error ( "This is a singleton, use getInstance to get an instance" ) ;
9+ return Wall . _instance ;
1010 Wall . _instance = this ;
1111 }
1212 public setHeight ( height :number ) {
@@ -34,3 +34,6 @@ var wall2 = Westeros.Wall.getInstance();
3434wall2 . getStatus ( ) ;
3535var wall3 = new Westeros . Wall ( ) ;
3636wall3 . getStatus ( ) ;
37+ wall3 . setHeight ( 20 ) ;
38+ var wall4 = new Westeros . Wall ( ) ;
39+ wall4 . getStatus ( ) ;
You can’t perform that action at this time.
0 commit comments