Java作业,求大哥大姐给个答案,要不我的选修就挂了,谢谢......
来源:百度知道 编辑:UC知道 时间:2024/05/26 08:14:19
public class PersonTest {
public static void main(String[] args) {
Person person = new Person("Allen", "male", 18);
System.out.println(person.toString());
// reset the name
person.setName("John");
// reset the sex
person.setSex("female");
// reset the age
person.setAge(20);
System.out.println(person.toString());
}
}
class Person {
// name
private String name;
// sex
private String sex;
// age
private int age;
// constructor
public Person(String name, String sex, int age) {
this.name = name;
this.sex = sex;
this.age = age;
}
public String getName() {
return this.name;
}
public String getSex() {
return sex;
}
public void setSex(String argSex) {
sex = argSex;
}
public in