diff --git a/src/main/java/com/pnkx/designpatterns/builder/BYDBuilder.java b/src/main/java/com/pnkx/designpatterns/builder/BYDBuilder.java new file mode 100644 index 0000000..b7c9190 --- /dev/null +++ b/src/main/java/com/pnkx/designpatterns/builder/BYDBuilder.java @@ -0,0 +1,12 @@ +package com.pnkx.designpatterns.builder; + +/** + * BYDBuilder + * + * @author 裴浩宇 + * @version 1.0 + * @date 2023/10/27 15:15 + * @description BYD汽车建造 + */ +public class BYDBuilder { +} diff --git a/src/main/java/com/pnkx/designpatterns/builder/Builder.java b/src/main/java/com/pnkx/designpatterns/builder/Builder.java new file mode 100644 index 0000000..25ca02c --- /dev/null +++ b/src/main/java/com/pnkx/designpatterns/builder/Builder.java @@ -0,0 +1,38 @@ +package com.pnkx.designpatterns.builder; + +/** + * Builder + * + * @author 裴浩宇 + * @version 1.0 + * @date 2023/10/27 14:23 + * @description 建造者 + */ +public abstract class Builder { + + // 车 + protected Car car = new Car(); + + /** + * 建造发动机 + */ + public abstract void buildEngine(); + + /** + * 建造轮胎 + */ + public abstract void buildTire(); + + /** + * 建造座位 + */ + public abstract void buildSeat(); + + /** + * 获取车 + * @return 车 + */ + public Car getCar() { + return car; + } +} diff --git a/src/main/java/com/pnkx/designpatterns/builder/Car.java b/src/main/java/com/pnkx/designpatterns/builder/Car.java new file mode 100644 index 0000000..98cb5e6 --- /dev/null +++ b/src/main/java/com/pnkx/designpatterns/builder/Car.java @@ -0,0 +1,43 @@ +package com.pnkx.designpatterns.builder; + +/** + * Car + * + * @author 裴浩宇 + * @version 1.0 + * @date 2023/10/27 14:20 + * @description 产品类——车 + */ +public class Car { + + // 发动机 + private String engine; + // 轮胎 + private String tire; + // 座位 + private String seat; + + public String getEngine() { + return engine; + } + + public void setEngine(String engine) { + this.engine = engine; + } + + public String getTire() { + return tire; + } + + public void setTire(String tire) { + this.tire = tire; + } + + public String getSeat() { + return seat; + } + + public void setSeat(String seat) { + this.seat = seat; + } +}