From a568aa82416836ff1f810af3cf35b50e45a44d68 Mon Sep 17 00:00:00 2001 From: bingor_yhj Date: Tue, 18 Oct 2022 19:45:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9D=A6=E5=85=8B=E5=A4=A7=E6=88=98(=E4=B8=80?= =?UTF-8?q?=E6=9C=9F)-=E8=AE=BE=E8=AE=A1=E6=A8=A1=E5=BC=8F=E7=89=88-Builde?= =?UTF-8?q?r=E6=A8=A1=E5=BC=8F1.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/msb/builder/Main.java | 8 ++++---- src/main/java/com/msb/builder/Person.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/msb/builder/Main.java b/src/main/java/com/msb/builder/Main.java index 8bace65..e0a81aa 100644 --- a/src/main/java/com/msb/builder/Main.java +++ b/src/main/java/com/msb/builder/Main.java @@ -17,10 +17,10 @@ public class Main { TerrainBuilder terrainBuilder = new ComplexTerrainBuilder(); Terrain terrain = terrainBuilder.buildWall().buildFort().buildMine().build(); - Person person = new Person.PersonBuilder().buildBasicInfo(1, "bingor") - .buildAge(33) - .buildScore(100) - .buildLocation("机场路", "8号") + Person person = new Person.PersonBuilder().basicInfo(1, "bingor") + .age(33) + .score(100) + .location("机场路", "8号") .build(); } } diff --git a/src/main/java/com/msb/builder/Person.java b/src/main/java/com/msb/builder/Person.java index 72167f3..5ae6f34 100644 --- a/src/main/java/com/msb/builder/Person.java +++ b/src/main/java/com/msb/builder/Person.java @@ -21,23 +21,23 @@ public class Person { public static class PersonBuilder { Person person = new Person(); - public PersonBuilder buildBasicInfo(int id, String name) { + public PersonBuilder basicInfo(int id, String name) { person.id = id; person.name = name; return this; } - public PersonBuilder buildAge(int age) { + public PersonBuilder age(int age) { person.age = age; return this; } - public PersonBuilder buildScore(int score) { + public PersonBuilder score(int score) { person.score = score; return this; } - public PersonBuilder buildLocation(String street, String roomNo) { + public PersonBuilder location(String street, String roomNo) { person.location = new Location(street, roomNo); return this; }