Skip to content

Commit

Permalink
Revert "工厂方法模式实战 (#250)"
Browse files Browse the repository at this point in the history
This reverts commit f3c756e.
  • Loading branch information
hcsp-bot committed Sep 22, 2021
1 parent f3c756e commit b4c43f0
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/main/java/com/github/hcsp/encapsulation/Cat.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,11 @@ public class Cat {
*
* <p>否则,返回一只新创建的猫
*
* @param age 年龄
* @param age 年龄
* @param name 名字
* @return 创建的猫
*/
public static Cat newCat(String name, int age) {
boolean isInvalidAge = age < 0;
boolean isInvalidName = name == null || "".equals(name);
if (isInvalidAge || isInvalidName) {
return INVALID_CAT;
}
return new Cat(name, age);
}

Cat(String name, int age) {
this.name = name;
this.age = age;
}

public static Cat newCat(String name, int age) {}

public String getName() {
return name;
Expand Down

0 comments on commit b4c43f0

Please sign in to comment.