赞
踩
Time Limit: 1000 Memory Limit: 65535
Submit: 990 Solved: 362
Description
构造Person类。包括姓名(name),性别(sex)和年龄(age)。提供所有属性的set和get函数,提供print函数打印其信息
Input
姓名(name),性别(sex)和年龄(age)
Output
用户信息
Sample Input
Lucy male 23
Sample Output
name:Lucy; sex:male; age:23
- class Person
- {
- private String name;
- private String sex;
- private int age;
- public Person()
- {
- name = null;
- sex = null;
- age = 0;
- }
- public void setName(String name)
- {
- this.name = name;
- }
- public void setSex(String sex)
- {
- this.sex = sex;
- }
- public void setAge(int age)
- {
- this.age = age;
- }
- public void print()
- {
- System.out.print("name:"+name+"; sex:"+sex+"; age:"+age);
- }
-
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。