From 4b402611aac95f4fe623a54949409ecb4e86a596 Mon Sep 17 00:00:00 2001 From: richard1230 Date: Sat, 4 Jan 2020 17:26:10 +0800 Subject: [PATCH 1/2] voerload --- src/main/java/com/github/hcsp/objectbasic/Cat.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/github/hcsp/objectbasic/Cat.java b/src/main/java/com/github/hcsp/objectbasic/Cat.java index c9d7663..b1f73f1 100644 --- a/src/main/java/com/github/hcsp/objectbasic/Cat.java +++ b/src/main/java/com/github/hcsp/objectbasic/Cat.java @@ -11,11 +11,13 @@ public class Cat { /** 创建一只指定名字的猫,age的默认值是1,cute的默认值是true */ public Cat(String name) { // 请在这里使用this()调用其他的构造器 + this(name,2,true); } /** 创建一只指定名字和年龄的猫,cute的默认值是true */ public Cat(String name, int age) { // 请在这里使用this()调用其他的构造器 + this(name,age,true); } /** 创建一只指定名字、年龄和萌属性的猫 */ From b7a88af9c07d916675810b10fbb161efd29708ca Mon Sep 17 00:00:00 2001 From: richard1230 Date: Sat, 4 Jan 2020 17:27:44 +0800 Subject: [PATCH 2/2] overload --- src/main/java/com/github/hcsp/objectbasic/Cat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/hcsp/objectbasic/Cat.java b/src/main/java/com/github/hcsp/objectbasic/Cat.java index b1f73f1..6bb16f6 100644 --- a/src/main/java/com/github/hcsp/objectbasic/Cat.java +++ b/src/main/java/com/github/hcsp/objectbasic/Cat.java @@ -16,7 +16,7 @@ public Cat(String name) { /** 创建一只指定名字和年龄的猫,cute的默认值是true */ public Cat(String name, int age) { - // 请在这里使用this()调用其他的构造器 + // 在这里使用this()调用其他的构造器 this(name,age,true); }