@@ -6,6 +6,7 @@ var Westeros;
66 function KingJoffery ( ) {
77 }
88 KingJoffery . prototype . makeDecision = function ( ) {
9+ console . log ( "Decision made by King Joffery" ) ;
910 } ;
1011 KingJoffery . prototype . marry = function ( ) {
1112 } ;
@@ -17,6 +18,7 @@ var Westeros;
1718 function LordTywin ( ) {
1819 }
1920 LordTywin . prototype . makeDecision = function ( ) {
21+ console . log ( "Decision made by Lord Tywin" ) ;
2022 } ;
2123 return LordTywin ;
2224 } ) ( ) ;
@@ -48,6 +50,7 @@ var Westeros;
4850 function KingAerys ( ) {
4951 }
5052 KingAerys . prototype . makeDecision = function ( ) {
53+ console . log ( "Decision made by King Aerys" ) ;
5154 } ;
5255 KingAerys . prototype . marry = function ( ) {
5356 } ;
@@ -59,6 +62,7 @@ var Westeros;
5962 function LordConnington ( ) {
6063 }
6164 LordConnington . prototype . makeDecision = function ( ) {
65+ console . log ( "Decision made by Lord Connington" ) ;
6266 } ;
6367 return LordConnington ;
6468 } ) ( ) ;
@@ -81,3 +85,32 @@ var Westeros;
8185 } ) ( Westeros . Ruling || ( Westeros . Ruling = { } ) ) ;
8286 var Ruling = Westeros . Ruling ;
8387} ) ( Westeros || ( Westeros = { } ) ) ;
88+
89+ var Westeros ;
90+ ( function ( Westeros ) {
91+ ( function ( Ruling ) {
92+ var CourtSession = ( function ( ) {
93+ function CourtSession ( abstractFactory ) {
94+ this . abstractFactory = abstractFactory ;
95+ this . COMPLAINT_THRESHOLD = 10 ;
96+ }
97+ CourtSession . prototype . complaintPresented = function ( complaint ) {
98+ if ( complaint . severity < this . COMPLAINT_THRESHOLD ) {
99+ this . abstractFactory . getHandOfTheKing ( ) . makeDecision ( ) ;
100+ } else
101+ this . abstractFactory . getKing ( ) . makeDecision ( ) ;
102+ } ;
103+ return CourtSession ;
104+ } ) ( ) ;
105+ Ruling . CourtSession = CourtSession ;
106+ } ) ( Westeros . Ruling || ( Westeros . Ruling = { } ) ) ;
107+ var Ruling = Westeros . Ruling ;
108+ } ) ( Westeros || ( Westeros = { } ) ) ;
109+
110+ var courtSession1 = new Westeros . Ruling . CourtSession ( new Westeros . Ruling . Targaryen . TargaryenFactory ( ) ) ;
111+ courtSession1 . complaintPresented ( { severity : 8 } ) ;
112+ courtSession1 . complaintPresented ( { severity : 12 } ) ;
113+
114+ var courtSession2 = new Westeros . Ruling . CourtSession ( new Westeros . Ruling . Lannister . LannisterFactory ( ) ) ;
115+ courtSession2 . complaintPresented ( { severity : 8 } ) ;
116+ courtSession2 . complaintPresented ( { severity : 12 } ) ;
0 commit comments