From 2e9eff0eadc26f9486744628ed57f60a30c5bed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A3=B4=E6=B5=A9=E5=AE=87?= <617594538@qq.com> Date: Fri, 27 Oct 2023 18:28:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BB=BA=E9=80=A0=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designpatterns/builder/BYDBuilder.java | 12 ++++++ .../pnkx/designpatterns/builder/Builder.java | 38 ++++++++++++++++ .../com/pnkx/designpatterns/builder/Car.java | 43 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 src/main/java/com/pnkx/designpatterns/builder/BYDBuilder.java create mode 100644 src/main/java/com/pnkx/designpatterns/builder/Builder.java create mode 100644 src/main/java/com/pnkx/designpatterns/builder/Car.java 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; + } +}