刘关张三结义(第七次作业)

package pjh1;

public class A {
    public int id;
    public String name;
    public int age;
    public String city;
    public String introduce() {
    return "我的ID是" + id + ", 名字是" + name + ", 年龄是" + age + ", 居住地是" + city ;
    } 
}
package pjh1;

public class B {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        A p1=new A();
        A p2=new A();
        A p3=new A();
        A p4=new A();
        p1.id=110001; p1.name="刘备";
        p1.age=43; p1.city="蜀国";
        p2.id=110002; p2.name="关羽";
        p2.age=35; p2.city="蜀国";
        p3.id=110003; p3.name="张飞";
        p3.age=32; p3.city="蜀国";
        p4.id=110004; p4.name="诸葛亮";
        p4.age=25; p4.city="蜀国";
        System.out.println(p1.introduce());
        System.out.println(p2.introduce());
        System.out.println(p3.introduce());
        System.out.println(p4.introduce());

        }
}

刘关张三结义(第七次作业)_第1张图片刘关张三结义(第七次作业)_第2张图片

转载于:https://www.cnblogs.com/520peng/p/7754464.html

你可能感兴趣的:(刘关张三结义(第七次作业))