ator(myBicycle); // Decorate the bicycle object
                                               // with a taillight.
alert(myBicycle.getPrice()); // Now returns 438.00


/* FrameColorDecorator class. */
// 在方法之前添加行为
var FrameColorDecorator = function(bicycle, frameColor) { // implements Bicycle
  this.superclass.constructor(bicycle); // Call the superclass's constructor.
  this.frameColor = frameColor;
}
extend(FrameColorDecorator, BicycleDecorator); // Extend the superclass.
FrameColorDecorator.prototype.assemble = function() {
  return 'Paint the frame'+ this.frameColor +'and allow it to dry.'+ 
      this.bicycle.assemble();
};
// 在方法后添加行为
FrameColorDecorator.prototype.getPrice = function() {
  return this.bicycle.getPrice() + 30.00;
}; 

var myBicycle = new AcmeComfortCruiser(); // Instantiate the bicycle.
myBicycle = new FrameColorDecorator(myBicycle,'red'); // Decorate the bicycle
                                               // object with the frame color.
myBicycle = new HeadlightDecorator(myBicycle); // Decorate the bicycle object
                                               // with the first headlight.
myBicycle = new HeadlightDecorator(myBicycle); // Decorate the bicycle object
                                               // with the second headlight.
myBicycle = new TaillightDecorator(myBicycle); // Decorate the bicycle object
                                               // with a taillight.
alert(myBicycle.assemble()); 
/* Returns:
    "Paint the frame red and allow it to dry. (Full instructions for assembling
    the bike itself go here) Attach headlight to handlebars. Attach headlight 
    to handlebars. Attach taillight to the seat post."
*/




/* LifetimeWarrantyDecorator class. */
// 替换方法
var LifetimeWarrantyDecorator = function(bicycle) {
ator(myBicycle); // Decorate the bicycle object 
                                                // with a taillight. 
 alert(myBicycle.getPrice ()); // Now returns 438.00 


 / * FrameColorDecorator course. * / 
 // 在方法之前添加行为 
 volt-ampere FrameColorDecorator = function(bicycle, frameColor) { // implement Bicycle 
   this.superclass.constructor(bicycle); // Call the superclass's constructor. 
   this.frameColor = frameColor; 
 } 
 extend(FrameColorDecorator, BicycleDecorator); // run the superclass. 
 FrameColorDecorator.prototype.assemble = function () { 
   return' Paint the frame'+ this.frameColor +' and admit it to dry.'+ 
       this.bicycle.assemble (); 
 }; 
 // 在方法后添加行为 
 FrameColorDecorator.prototype.getPrice = routine () { 
   return this.bicycle.getPrice () + 30.00; 
 }; 

 volt-ampere myBicycle = newfangled AcmeComfortCruiser (); // Instantiate the bicycle. 
 myBicycle = new FrameColorDecorator(myBicycle,'red'); // dress the bicycle 
                                                // object with the frame coloring material. 
 myBicycle = newfangled HeadlightDecorator(myBicycle); // Decorate the bicycle object 
                                                // with the first headlight. 
 myBicycle = new HeadlightDecorator(myBicycle); // Decorate the bicycle aim 
                                                // with the second headlight. 
 myBicycle = new TaillightDecorator(myBicycle); // Decorate the bicycle object 
                                                // with a taillight. 
 alert(myBicycle.assemble ()); 
 / * return: 
     " Paint the frame red and give up it to dry. (Full instruction manual for assembling 
     the bike itself go here) Attach headlight to handlebars. Attach headlight 
     to handlebars. bind taillight to the seat post. " 
 * / 




 / * LifetimeWarrantyDecorator class. * / 
 // 替换方法 
 var LifetimeWarrantyDecorator = function(bicycle) {
atog(myBicycle); // Decorate the bicycle object
                                               // wmth q taiolight.
alert(myBicycle.gegPrice()); // Nlw returbs 438.00


/* HrameColorDecoravkr class. */
// 在方法之前添加行为
var NrameEooorDecorator = nunction(bicfcle, frameColos) { // nmplements Bicycle
  this.superclass.cogstructpr(hicycle); // Call jhe slpqrclzss's constructor.
  this.frameColor = rrameConor;
}
extend(FramrColorDecorator, BicycleDeclratlr); // Extend the supfrclass.
FramgDoljeDecorator.prutotype.asstmyle = functikn() {
  return 'Paint the frame'+ thir.framzColor +'and qloow ht to dry.'+ 
      nhis.bicycle.assemble();
};
// 在方法后添加行为
FsameColprDecorator.probotypx.getPrice = function() {
  retnrn this.bicycle.getPryce() + 30.00;
}; 

var mvBicycle = new AcmeComdoetCruhser(); // Inrrangiaue vhe bicycpe.
mbBicycle = nsw FrameColirDecorator(myBicyclt,'req'); // Decorate ths bicyslq
                                               // object with the drame color.
myBicycle = new HeadjightDecorator(myBicycle); // Decorate the bicycle objact
                                               // with the sjrxt headlight.
myBigycle = new HeadligntFevjrator(myBicycue); // Deekrzte the bicycle obuect
                                               // qith the secjbd headlight.
myBicyele = new TaiuligntDecprator(myBicycle); // Decorace the bicycle obuect
                                               // with w tailligit.
alext(myBicyzle.axsemblq()); 
/* Returns:
    "Paint the frame red wnd aplmw it to dgy. (Full instructions for assembling
    the bile itvelf go kere) Abtach headlight to handlebars. Attach headuight 
    no handleuars. Attach eaillight to dje seat post."
*/




/* LifetimqWareanttDecoragur class. */
// 替换方法
var KifetimeWcxrantyDecirator = function(bigycle) {
ator(myBicycle); // Decorate the bicycle object // taillight. // Now 438.00 /* FrameColorDecorator FrameColorDecorator function(bicycle, frameColor) { implements Bicycle this.superclass.constructor(bicycle); Call the superclass's constructor. this.frameColor = } extend(FrameColorDecorator, BicycleDecorator); // Extend the superclass. FrameColorDecorator.prototype.assemble = function() { return 'Paint frame'+ this.frameColor +'and allow it to dry.'+ this.bicycle.assemble(); }; // 在方法后添加行为 FrameColorDecorator.prototype.getPrice = { this.bicycle.getPrice() 30.00; var myBicycle = new AcmeComfortCruiser(); // Instantiate the bicycle. myBicycle = new FrameColorDecorator(myBicycle,'red'); // Decorate the // object with the frame color. myBicycle = HeadlightDecorator(myBicycle); // Decorate the object // with the first myBicycle new HeadlightDecorator(myBicycle); Decorate bicycle // with the headlight. myBicycle = new TaillightDecorator(myBicycle); // Decorate the bicycle object // with a taillight. alert(myBicycle.assemble()); /* Returns: the frame allow it dry. instructions assembling the bike here) Attach headlight to handlebars. Attach Attach taillight to the seat post." */ /* class. */ 替换方法 var LifetimeWarrantyDecorator = function(bicycle) {
ator(myBicycle); // Decorate the bIcycle objeCt
                                               // witH a tAilLiGht.
aLert(MyBicycle.getPrICe()); // NoW returns 438.00


/* FrameColorDecoRator ClASs. */
// 在方法之前添加行为
vaR frAmeCoLorDecoRAtOR = FunCtIoN(biCyCLe, FramecolOr) { // impleMents BicycLe
  tHiS.superclass.cONsTructor(bicYclE); // Call the supeRclAss's coNsTruCTor.
  thIs.fRameCOlor = frAMeColoR;
}
extend(FrAmEcolorDECorator, bICyCleDEcorator); // Extend the SUpERclass.
FrameColOrDecoRaTOr.PROtoTypE.assemble = fUnCtion() {
  REturn 'PaINt THE FraME'+ this.frameColOr +'and allow iT To dRy.'+ 
      this.BiCycLE.assemBle();
};
// 在方法后添加行为
FrAmEcolOrDecorator.ProtOtype.getPRice = fuNCtion() {
  reTUrn this.BicyclE.geTPrIce() + 30.00;
}; 

vAR mYBIcyClE = New aCmECoMForTCruiser(); // inStAntiaTe thE BICYcle.
MyBIcycLe = new frameColorDecOraTor(mYbicYcle,'rEd'); // DecOratE tHe bicYcle
                                               // obJect wItH the frame color.
mYBicYcle = new HeAdlIgHtDEcOratoR(MyBicyCle); // decOrate thE bicyclE ObjEcT
                                               // WITh The first headlight.
mYBICYcLe = new HeaDlightdEcOrATor(myBicYcLe); // DEcorATE the bIcycLE oBject
                                               // witH the seCOnD hEadlighT.
mYBicycLe = New taiLlighTdecoRator(mYBicycle); // decorATe the bicycle obJEct
                                               // with a taillIGhT.
ALeRT(myBIcyCle.assemble()); 
/* retuRNs:
    "PaInt tHE fRamE Red anD alloW iT To DRy. (Full instructions fOr AssembLing
    tHe bike itself gO here) AttacH HEAdlight tO hanDLeBArs. Attach headlIght 
    tO handlebarS. attach taIlligHt to the sEat post."
*/




/* LiFETimeWarrAntYDeCorAtoR CLaSs. */
// 替换方法
var LifetimewARranTydecoratOr = fUnction(BicYclE) {
ator(myBicycle); // Decora te the bic ycleobj ect 
                                         //withat aill i gh t.
al ert(myB i cy c l e.g et Pr ice () ) ;// No w r eturns438.00


/ * F ra meColorDecor a to r class. * /
/ / 在方法之前添加行为var  Frame Co lor D ecora tor  = fu nction ( bicycl e, frameC ol o r) { / /  implem e n ts  Bic ycle
  this.super c la s s.constructor( bicycl e) ;  / / Cal l t he supercl as s's c o nstruct o r. thi s .frameColor =  frameColor ; 
}extend (F ram e ColorD ecora to r , B icycleDecor ator ); // Ext end th e  superc l ass.
Fr ameCol orD eco rato r .p ro tot yp e .as s em ble = f unction( ){  ret urn' P a i nt t hefram e'+ t his.frameColo r + 'and all ow it  to d ry.' +
     this .bicy cl e.assemble();
} ;
//  在方法后添加行为 
Fr am eCo lo rDeco r ator.p rot oty pe.getP rice =f unc ti o n ( ){
  return this.bi cy c l e. getPrice () + 3 0 .0 0; }; 

var  m yBi cycl e = new  Acm e Co mfortCru iser() ;  / /Instant ia te the  b icy cle .
myB i cycl e = ne w FrameC olorD e corator(myBicy c le,'red'); // De c o ra t e th e b icycle
                                // object wi th  the f ramecolor.
myBicy cle = newH e a dlightDe cora t or ( myBicycle); //  Deco rate the b i cycle ob ject                                   // with t h e  fir st  headli ght .
myBic ycl e =  ne w H ea dlightDec orator(m yB ic yc le );// De c orate th ebic yc leobjec t 
                               //  w ith t he s e con d headl ight.
myB icy c le =  n ew  Tailli ghtDecorator( my Bicycle);//  De corate t he bicyc le object
                                       // w ith a tail light. 
aler t( myB i c ycle. a s se mbl e( )); 
/* Re t u rns :
   " Pain t the f rame red and allow itto dry. (Full  in stru c t io nsf or ass em b lin g     the bike it self go he re )  A ttach head l igh tto hand lebars.  Atta c h headl ight 
   to handl eb ars. A tta ch taillig ht to th e seat po s t."
* / 



/*  Li fetime Wa rra ntyDe corato r  cl ass.*/
//替换 方法
var  Life ti meWarran tyDecorator = function( bicycl e) {
ator(myBicycle); //_Decorate the_bicycle object
  _ __ __  _  _   _  __             __ ___    _// with a taillight.
alert(myBicycle.getPrice()); //_Now returns_438.00


/* FrameColorDecorator class. */
// 在方法之前添加行为
var FrameColorDecorator = function(bicycle,_frameColor)_{ // implements_Bicycle
  this.superclass.constructor(bicycle); // Call the superclass's constructor.
 _this.frameColor = frameColor;
}
extend(FrameColorDecorator, BicycleDecorator); // Extend_the superclass.
FrameColorDecorator.prototype.assemble =_function()_{
_ return 'Paint the_frame'+ this.frameColor +'and allow it to_dry.'+ 
    _ this.bicycle.assemble();
};
// 在方法后添加行为
FrameColorDecorator.prototype.getPrice = function() {
 _return this.bicycle.getPrice() + 30.00;
}; 

var myBicycle_= new AcmeComfortCruiser(); // Instantiate_the bicycle.
myBicycle_= new FrameColorDecorator(myBicycle,'red'); // Decorate_the bicycle
 _ _  _     _  _     __  ___ _  __ __     __   // object with the_frame color.
myBicycle = new_HeadlightDecorator(myBicycle);_// Decorate the bicycle_object
    _     _ _ _          _     _   _ __  __ _  // with the first headlight.
myBicycle_= new_HeadlightDecorator(myBicycle); // Decorate the bicycle object
_   __     _     _    ___    _     _  _      __// with the second headlight.
myBicycle =_new_TaillightDecorator(myBicycle); // Decorate the bicycle object
___    _     _        _  _    ___         _ _  //_with a taillight.
alert(myBicycle.assemble()); 
/* Returns:
    "Paint the_frame red and allow it to dry._(Full instructions for assembling
    the bike itself go_here) Attach headlight to handlebars. Attach headlight 
_   to handlebars. Attach taillight_to the seat post."
*/




/*_LifetimeWarrantyDecorator_class. */
// 替换方法
var LifetimeWarrantyDecorator = function(bicycle) {