Person
public class Person {
private String name;
private int age;
public Person() {
super();
}
public Person(String name, int age) throws AgeException {
super();
setName(name);
setAge(age);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) throws AgeException {
if(age > 0 && age<=150){
this.age = age;
}else{
//System.out.println("年龄不合理!!!");
//throw new NullPointerException();
throw new AgeException("年龄不合理!");
}
System.out.println("让我看看怎么不合理!!!");
}
@Override
public String toString() {
return "Person [name=" + name + ", age=" + age + "]";
}
}
private String name;
private int age;
public Person() {
super();
}
public Person(String name, int age) throws AgeException {
super();
setName(name);
setAge(age);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) throws AgeException {
if(age > 0 && age<=150){
this.age = age;
}else{
//System.out.println("年龄不合理!!!");
//throw new NullPointerException();
throw new AgeException("年龄不合理!");
}
System.out.println("让我看看怎么不合理!!!");
}
@Override
public String toString() {
return "Person [name=" + name + ", age=" + age + "]";
}
}
上一篇:A blooming tree
下一篇:北方 倪健
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
文章热度:☆☆☆☆☆
文章难度:☆☆☆☆☆
文章质量:☆☆☆☆☆
说明:系统根据文章的热度、难度、质量自动认证,已认证的文章将参与打字排名!
本文打字排名TOP20
登录后可见