6、 声明类Student,包含3个成员变量:name、age、score,

/*
分析:1,需要3个成员变量,name,  age,   score。
  2,可以通过set, get方法访问。

思路:  1,创建一个student类, 类里面包含 name,age, score,三个变量。
   2,设置成私有, 对外提供set,get,方法。
   3,在主函数中创建student("张三", 22, 95)类型的对象。
*/
class  Demo6 {
 public static void main(String[] args) {
             Student  s  =  new  Student("张三", 22, 95); //创建new  Student("张三", 22, 95)对象。 
    }
}

class   Student  {
 //私有成员变量。
 private String  name ;
 private int   age;
 private int   score;
 
 //对外提供 name,age, score 的 set,get方法。
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public int getAge() {
  return age;
 }
 public void setAge(int age) {
  this.age = age;
 }
 public int getScore() {
  return score;
 }
 public void setScore(int score) {
  this.score = score;
 }
 
 //构造函数。
 public Student(String name,  int  age,   int score){
  this.age = age;
  this.name = name ;
  this.score = score;
  System.out.println("姓名:"+getName() +","+"年龄:"+ getAge() + ","+"分数:"+getScore()); 
 }
}