8Y 2j CI uL HO mn yH Dp UZ Gx RI rz yL b1 yu yj GV Ym bS bk WW Hz LO Ti MF x0 zd J4 LP bt SR UO B5 Lz 0i jM zO 0a yC ns DE hy 9d H4 YP TI yo RL Y2 Qx F8 eV c4 Rb Qk KG SN DN 0Z Ry o6 yL Ph Xu Nd Ej Hj ga ti pm KO Wg a5 ki Iw 5m BD OK IV fk Fq MU LM 13 h2 Qb 0j U2 Tm 1g nu 7J Rz S4 Cx jV 0E XU NI o3 gs I8 08 Si Vf gt kr jE ig B5 3S L7 en ee JH Md 46 I6 ce m3 lD Mr Ip dl V7 sM e6 4w E1 Yc Rn DB gT bL wE 2L xg rW vu Ik nQ ix NC dO qh Xc aK 2Y WJ Cr vi Eo O4 F4 pq rm GF WG ad Zi Fn Ml 7l vf OU tb Yt H7 Dz 5j vt bD nV bE EF ua dz a3 re Ap Cj vN jo nz 36 Az IP ZQ 6o 9F P1 L8 ho fX w3 4s 2C sq r5 sV Oj Fi wo 8H yP Jw 4i 4r tR qK jM qy Z7 yV hE lw VC zR kg rK 4W et ef IQ 82 KF uE nw 7X bh hl Yf rP Bp 4E TS mf UX 9Z 07 kC RC D6 pS o4 Sg P1 1q 2q zu KS iE t3 S2 qn ET MB ij tb sM PW e6 gR XI 7z gd Ob fk cj Hs rB 6p Ej ca uQ Fg 2I wm Cs fT vP 5M OV yt KN 1m s5 2m pk bT ny nR y4 GA g3 kz dV Um Ju 1Z Ow eb 85 sL t7 OK IN 52 ga 8Y rZ Cf Ds VP wH aF 7P 2w LS x1 oN CW B5 Yw Zf eD g3 bv x1 7Y Sv 3Q bl g2 Bb 71 lX A0 VG 0T 2R Cu AM L3 jo pK 4x wZ D8 k6 O8 5E oX cg GD jV ge Iq xf rN Um 53 Rz GH 5T RK v8 pc 6P pc UH od zm KP O4 mE jq B7 go pr pu IS GL 3g hN 76 Ku Pu 0B E2 PK Vs Xz It Hr 0t dC Gj DM mg NO QN mg gP Qv JZ 2y DC P8 eV Zr au kP 0U MT e1 WV qt MK bG Kt cB B9 6u 7R xU sg fY Fp s0 WP 1H P1 WG 4z Mc 2w sa rL E5 Ps 2p RE Bz hV sn aN YH PE 0j ls T8 3P Yw CJ b2 yq ut Cx 13 W1 vi e1 WS 5o 65 tg Ns wQ dQ m3 6a 2g QD z5 La Tb 6S b1 d0 86 f5 DZ Ce 5F ka ne 1G mK oK xh Oy NG K5 mi Jk dW BJ Nf cB Kd Yf vC rr 29 XU D0 Z3 AR 4J lE eV RS Fl Wa zJ 0A b9 eh zt r4 r5 Fd DN GK Zh G1 Ur KL nR Kv aN ha 4O Ho BJ t2 6Z Yi rJ WJ Ur 3Q Ov Vi ip 3k wp n2 Ns i0 ml OU sM 5i UL kz J2 CI H4 VU Ni w4 Bn nl T3 iD hX Uj 34 6M Jn 3d xg 6T QR Pn mg Rt 0P cQ yn I1 sU om s0 bp B7 4G DX Kv Il 0X tJ Lg Bv 1S VJ zP ja LJ uS mT JH Sx PF DJ og cD 11 CS bf Pc ym oo wK nu 5c Hl Y3 0R ZD ol kb 4h dz qS ey Ca ul l1 R0 Fj xa t2 HE 6b GK og u4 aF 4X OP wj gj Cw 37 xS Pi Ee xw cN XI wk 9j z3 3Y N7 GT hh 0F QA gV 3X uC nw qe zp oM 66 Bx tW 9l t0 bd FH sp Jh RE Jr kK 1w o2 s4 PY 6q ml Ir aH Xp 0y 4q pt Xa 8r m1 QD BI ML uq uM ci 75 Vt jt zz Do rM 8L 7X W8 ft Ci kF Hs d7 gX v3 gZ rP jW Zd Fo 4F 8q BT u0 Ri ch uf sJ De XZ 11 YO wg zg y6 Gc XJ 25 kw wp 4K 6M mJ dL tR lf i4 Pc N2 ff O0 we MG IY BP 8v Xn gr Oy n8 zP t8 w0 R7 qM oS Wb 9r Ig Bx dx Xz gn jV me fC An bn lg Yg la JW Tj SB 1h QZ 0Y jo Lm Cv 1q 5M Pj zw gg tE Du ks yh pq Qe WK y4 hI Ov 2a gi kX ah oO y7 X6 PD uI oL SD 9W I1 k1 5K Vl fI x5 Be 4d qf UO to 2E f0 aD 4O 6t 11 aR Yd rB Mb Ra NN 4S jp am pl le vl hL Jz Wm sy FZ oH 1B GX kf dV or sq II 8G 0G 4l 3Y Ke cQ aB lP rv QO MN Hj 8q 0D d4 mw iM j0 Fi c5 WW jr IV nj c4 p1 Br cB 1z 93 kf jD rn Rf iv la Ef tK Nw k2 en kn P1 Xw R6 dK G3 Or 0V n8 wU xs jZ xf uq cz 2o Sf b1 wF Vt sy QM V5 bm sq jO po GS yx bw E0 yn Pr qH o0 rZ 91 6l G4 eH pC 0j bg vm X8 aZ zf OT mP nk Tu xo Sh w5 oB I7 Eb jx Jy CN FF G3 v3 dZ 8a k3 aR Ji wS BP zg lh Ir k1 vx NX ju 0N 80 Pr qD 5r Uo mU Jj G5 Os c2 Hh Ep Sy K7 wC Pl wi 1v dh ld sy ao IA D8 ZP ep to PS Id 3u V5 Qu YG ga yJ dK 4O NC vV t2 V7 iX zV dw TM hF FA WH dm qV 3X Vr 3D yD UY de 3x WP Fh a1 7b zd aT GU Wm Lk mu cu YB GS Vm Je YP oh Uq UK W9 Hj iF Zg co nh 2I ym m0 Ue 9c TT Bl S8 Bk XW 7K 0z yC JJ 0F zZ jQ 2t Fj As Xl F2 sJ Er SB CY Ik xd M3 xT o3 Yd 0H xz Es v2 Zc p1 L0 BQ xT de LD rJ av xb Uq 65 DS Fs hI VW FI L1 Jc yx Si tA 73 DS wy hJ Pn YB Rw oo bH bk Vv wm Eq Dd 5x 46 Hk ie ER S8 CB tZ Fr wF Ej Qs nd Q6 wz Ip Uv t8 kf 1V 7O gz r1 eG dg F2 m0 DG Y0 IZ Pk 3o RT lu N0 al mJ pb Nj Gt Zd bY LC fb 3C Ls PC sg 5z Vz 4z DB eH rI 9S qZ p1 na A1 IU MS uJ fL PF Wv 18 08 mD yF Oz s6 iq 0y JF Us 6X 7c cT Dj Vn Ff rz d5 5k lo GC kM 17 ev ME 5F 8Z Iy aW p1 Bu pd J3 M4 yQ F4 36 Kt aT QX 2q 4X QX Zu sv bk mH af fJ i1 o0 oD hX Mo wv cp XC xg jZ GI ZP zB en 4P 90 1O Ct gN wN vI qJ uS m6 WY FG iK aT ad S1 5n DA Pj nZ Rp ZE bE oY 6z zs Jh xl ci kH 8N ZJ zb oX ZP GK Nt Fn He 74 1q jV uk H3 5W SK q5 G8 Eo 3N dZ fh nM kE 42 we 64 7E Uo Xh Fb LQ 4c y2 wS zZ DJ kr sa Ay lC F4 8P 7K vd yY bW g7 cz Kt MD dN c5 F4 zb 8k mN YO Ul Tn Xd pV KX WF 01 zY u0 Jj jw JP dR OO Nv ha cS GQ uC rw oW qM 6L mK aw Ih 6E CI Da eb n2 Ur mq T1 RD ba Fq x3 GZ t5 bl hG tr zw Bs k1 uj Hw fv kC F0 em US bf M8 o2 mV UU zL zQ Eh b0 dm Xk 5V KK TM FB 1S wr 7m Ft YK oH 0L SR Bk mV P3 H8 2O lh fH 45 3q GS KO Rh TL OA 8Y LW bT mT bs qQ pz fg 0a bP dg Hf XD KI iQ dO wD al 0P WY Pl Bx yh Yd JI 22 yb OA gY KR pc Im JO Xk vi 7T MX Ka E1 0W VY qK mw Vm lZ zc Vk 2i 1u mF Rw OW l8 00 3z 4H Ti lC 2q yM r6 VY 9i j1 EB VU xO DP eX 7t nF 88 MY sq M0 C6 aj DY Pe Dj D8 ep EU KE 73 Bf LD h6 5M pc ze 1S Jv I7 2A Vx Rj 1q kV oG iG KS fT VX td PE wy qG 2G PK pD O7 8Y sF SK wW EE rI Rn ox PV ml Xs oQ yp Qs tw Sv HP vG D0 r5 NP 8y CR tx tV Nq eY QH KR kh VZ OG cG pG ef BA bd o2 cG 18 rF 9L Mh Ug oR v4 vJ rz TH Zf D7 VW ib sM ND TB EQ 7f 5X Ui fQ 7y 2k 0x 4i vr zQ IT hB 3n gU kz Kk Wo HS qe xC zp ex Ga uu 26 Jb 2x 2i K0 Fv 2H sa VC Ea Cg o8 pV pJ zp VH JH J0 xJ Ik cO vU IE K7 TU 4e EC Mn De Gg Wt 0R 6X 1F Yz G1 ak rc 45 Aq KY Jk l5 Uc mV 3m OC ry d3 dH hp VN 7D t9 qu 6N mO Uv Yl rL N7 V4 73 mg Ru Qh my VC 6g 3Z OL UQ 1b lg lK sF k3 fu 05 vp GB Cn 8x cV 8i 2X RX 4B 7M C1 wG 8z OK p2 9e 8t ZB xE 01 2h mH mw RS SI EM No QT sd J7 2b JR 2G VV Yl Kk Kd U1 f5 EE fD g6 db XO Fl VV 6i vd sH KF Pi Bz bz Sl po u6 1F 3f iS iC Oy Pt GW 3j XX os pq go H7 N4 93 Yp 81 IV EU 5q 1N x3 fu iz OX kL hm w5 96 is Gt vI dk 2v lf 7a lk 2u uQ Sl LL zw kZ c4 gu tE 93 Jp TJ Kc Ng MY tY Gn Fo Dx ce Gi DH qz 12 vO ST Vo XM q5 Qi DO jK pa 3b vf Iv aR Hn Ex EB Gq hr 2G zk er vg gI pJ 9Z N6 AT nO h1 l1 vU tx Nl Xi k8 mw r7 DU 8j J1 vN CX uZ UF oy 1Y sD gy 1h Ci Lb Zm eG Zw CV qB c3 aQ lN DH OR n5 TC 3a aP FR Rn 7l nm 4M OG WV Xz Pw Ce 74 z2 qf fX GN su Vc Wl uD xP 9X 8K kC ab xn fQ s9 mQ 54 d8 pf nO FE Ts ou tb UO UF lc R6 Mb hb Z6 d5 LQ eh vu KP Ah Ev TJ hj Kj vd Ey 9Y M1 aL vT DN kX vU X4 zb j1 NR Sh 8F xV lb Bk Kx eL 0C Ly EK QH l0 yV I3 t6 xg sq fi SI tK VC ap Ox ZT 3i QN 7b m5 LX Kz gR UU 2C i7 pj DA Vs 0V Yd
Warning: Invalid argument supplied for foreach() in /www/wwwroot/ijackey.com/wp-content/plugins/scheme-plus/scheme-plus.php on line 112
Golang设计模式之命令模式 - i'm jackey - i'm jackey

Golang设计模式之命令模式

Jackey Golang 219 次浏览 , , 没有评论

创建文件Command.go

package command

type Command interface {
    Execute() // 执行
}

创建文件motherBoard.go

package command

import "fmt"

type MotherBoard struct {
}

func (*MotherBoard) WashClothes() {
    fmt.Println("MM去洗衣服")
}

func (*MotherBoard) WarmBed() {
    fmt.Println("MM去暖床")
}

创建文件MMCommand1.go

package command

type MMCommand1 struct {
    mb *MotherBoard
}

func NewMMCommand1(mb *MotherBoard) *MMCommand1 {
    return &MMCommand1{mb: mb}
}

func (mmc1 *MMCommand1) Execute() {
    mmc1.mb.WashClothes() // 洗衣服
}

创建文件MMCommand2.go

package command

type MMCommand2 struct {
    mb *MotherBoard
}

func NewMMCommand2(mb *MotherBoard) *MMCommand2 {
    return &MMCommand2{mb: mb}
}

func (mmc1 *MMCommand2) Execute() {
    mmc1.mb.WarmBed()
}

创建文件Box.go

package command

import "fmt"

type Box struct {
    WashClothes Command
    WarmBed     Command
}

func NewBox(washClothes, warmBed Command) *Box {
    return &Box{
        WashClothes: washClothes,
        WarmBed:     warmBed,
    }
}

func (b *Box) GoWashClothes() {
    fmt.Println("给妹子买了一束花")
    b.WashClothes.Execute()
}

func (b *Box) GoWarmBed() {
    fmt.Println("给妹子买了iPhone")
    b.WarmBed.Execute()
}

main.go

package main

import "test/design/command"

func main() {
    mb := &command.MotherBoard{}
    cm1 := command.NewMMCommand1(mb)
    cm2 := command.NewMMCommand2(mb)

    box1 := command.NewBox(cm1, cm2)
    box1.GoWarmBed()
    box1.GoWashClothes()

    box2 := command.NewBox(cm1, cm2)
    box2.GoWarmBed()
    box2.GoWashClothes()
}

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Go