一、策略者模式
package com.citydo.faceadd.decoratormode;
public abstract class Attack implements GameRoleInterface {
public GameRoleInterface gr;
public Attack(GameRoleInterface gr){
this.gr = gr;
}
}
package com.citydo.faceadd.decoratormode;
public class Fb extends Attack{
public Fb(GameRoleInterface gr) {
super(gr);
}
@Override
public double money() {
return gr.money()+ 1300;
}
@Override
public String desc() {
return gr.desc() + "[長劍]";
}
}
package com.citydo.faceadd.decoratormode;
public interface GameRoleInterface {
double money();
String desc();
}
package com.citydo.faceadd.decoratormode;
public class Ms extends Attack {
public Ms(GameRoleInterface gr) {
super(gr);
}
@Override
public double money() {
return gr.money()+ 1200;
}
@Override
public String desc() {
return gr.desc() + "[盾]";
}
}
package com.citydo.faceadd.decoratormode;
public class Yase implements GameRoleInterface {
@Override
public double money() {
return 0.0;
}
@Override
public String desc() {
return "[洛克薩斯之手]";
}
}
package com.citydo.faceadd.decoratormode;
public class Yx extends Attack{
public Yx(GameRoleInterface gr) {
super(gr);
}
@Override
public double money() {
return gr.money()+ 1400;
}
@Override
public String desc() {
return gr.desc() + "[紅水晶]";
}
}
package com.citydo.faceadd.decoratormode;
public class Test {
public static void main(String[] args) {
GameRoleInterface ys = new Yase();
GameRoleInterface ys1 = new Fb(ys);
System.out.println(ys1.money());
System.out.println(ys1.desc());
GameRoleInterface ys2 = new Yx(new Fb(ys));
System.out.println(ys2.money());
System.out.println(ys2.desc());
GameRoleInterface ys3 =new Ms(new Yx(new Fb(ys)));
System.out.println(ys3.money());
System.out.println(ys3.desc());
}
}
二、前端腳手架Vue CLI
1、首先需要安裝node.js
2、隨便找一個目錄進行命令行操作
npm install -g @vue/cli
# OR
yarn global add @vue/cli
3、添加全局的擴展
npm install -g @vue/cli-service-global
4、創建項目
vue create hello-world
5、加載依賴
6、啓動前端服務
參考:VUE CLI