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; }