the fist blood of java-eclipse 哈哈哈哈 封装的运用

Posted 0929-luoyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了the fist blood of java-eclipse 哈哈哈哈 封装的运用相关的知识,希望对你有一定的参考价值。

class Student {
    private int id;
    public String name;
    public String sex;
    private int score;
    public void setId(int id) {
        this.id = id;
    }
    public int getId() {
        return id;
    }
    public void setScore(int score) {
        this.score = score;
    }
    public int getScore() {
        return score;
    }
    public void study() {
        System.out.println("好好学习,天天向上!");
    }
    public void exam() {
        System.out.println("考试不努力,毛大做兄弟!");
    }
}
public class Dome1 {
    public static void main(String[] args) {
        Student s= new Student();
        s.name="狗蛋";
        s.sex="男";
        s.setId(10086);
        s.setScore(450);
        System.out.println("姓名:"+s.name);
        System.out.println("性别:"+s.sex);
        System.out.println("学号:"+s.getId());
        System.out.println("最后一次模考成绩:"+s.getScore());
        s.study();
        s.exam();
    }

}

以上是关于the fist blood of java-eclipse 哈哈哈哈 封装的运用的主要内容,如果未能解决你的问题,请参考以下文章