3, design a student class student, and carry on the test
Requirements are as follows:
1 Student class contains name, score two attributes
2 Define two methods for each property, one for setting the value, and the other for getting the value.
3 The Student class defines a parameterless construction method and a construction method that receives two parameters, and two parameters are assigned to the name and grade attribute, respectively.
4 Create two student objects in the test class, one using the parameterless construction method, and then invoking the method to assign the name and the result, a constructor method with a parameter to assign the name and result in the constructor
Class Student {
private String name;
private double grade;
Public Student () {
} public
Student (String name, double grade) {
this.name = name;
This.grade = grade;
}
Public String GetName () {return
name;
}
public void SetName (String name) {
this.name = name;
}
Public double Getgrade () {return
grade;
}
public void Setgrade (double grade) {
this.grade = grade;
}
}
public class Test01 {public
static void Main (string[] args) {
Student stu1 = new Student ();
Stu1.setname ("Zhangsan");
Stu1.setgrade ();
Student STU2 = new Student ("Lisi";
}
}