You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
438 B
20 lines
438 B
package w5挑战版;
|
|
// 人类(父类)
|
|
public class Person {
|
|
private String name;
|
|
private int age;
|
|
|
|
public Person(String name, int age) {
|
|
this.name = name;
|
|
this.age = age;
|
|
}
|
|
|
|
// Getter
|
|
public String getName() { return name; }
|
|
public int getAge() { return age; }
|
|
|
|
// 通用方法
|
|
public void showInfo() {
|
|
System.out.println("姓名:" + name + ",年龄:" + age);
|
|
}
|
|
}
|