feat: 建造模式
This commit is contained in:
parent
208bc840bb
commit
2e9eff0ead
@ -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 {
|
||||
}
|
38
src/main/java/com/pnkx/designpatterns/builder/Builder.java
Normal file
38
src/main/java/com/pnkx/designpatterns/builder/Builder.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
43
src/main/java/com/pnkx/designpatterns/builder/Car.java
Normal file
43
src/main/java/com/pnkx/designpatterns/builder/Car.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user