package com.wsy.person;
2
3 public class Person {
4 private String name ;
5 private char sex;
6 private int age;
7 private String IDCardNumber;
8
9 public Person(String name, char sex, int age, String IDCardNumber) {
10
11 this.name = name;
12 this.sex = sex;
13 this.age = age;
14 this.IDCardNumber = IDCardNumber;
15 }
16 public void print()
17 {
18 System.out.println("姓名:"+name);
19 System.out.println("性别:"+sex);
20 System.out.println("年龄:"+age);
21 System.out.println("身份证号码:"+IDCardNumber);
22 }
23 public String getName() {
24 return name;
25 }
26 public void setName(String name) {
27 this.name = name;
28 }
29 public char getSex() {
30 return sex;
31 }
32 public void setSex(char sex) {
33 this.sex = sex;
34 }
35 public int getAge() {
36 return age;
37 }
38 public void setAge(int age) {
39 this.age = age;
40 }
41 public String getIDCardNumber() {
42 return IDCardNumber;
43 }
44 public void setIDCardNumber(String iDCardNumber) {
45 IDCardNumber = iDCardNumber;
46 }
47
48 }

package com.wsy.person;

public class TestPerson {

public static void main(String[] args) {
    Person p1 = new Person("王子",'男',18,"5201314");
    Person p2 = new Person("公主",'女',18,"52013");
    p1.print();
    p2.print();
} 

}

posted on 2019-06-09 20:48  黄章俊  阅读(95)  评论(0编辑  收藏  举报