1.先写一个Student类

public class Student {
    private String name;
    private int chinese;
    private int math;
    private int english;

    public Student() {
        super();
    }

    public Student(String name, int chinese, int math, int english) {
        this.name = name;
        this.chinese = chinese;
        this.math = math;
        this.english = english;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getChinese() {
        return chinese;
    }

    public void setChinese(int chinese) {
        this.chinese = chinese;
    }

    public int getMath() {
        return math;
    }

    public void setMath(int math) {
        this.math = math;
    }

    public int getEnglish() {
        return english;
    }

    public void setEnglish(int english) {
        this.english = english;
    }

    public int getTotal(){
        return (this.chinese + this.math + this.english);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", chinese=" + chinese +
                ", math=" + math +
                ", english=" + english +
                '}';
    }
}
Student

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-09-28
  • 2021-08-19
  • 2021-11-07
  • 2022-12-23
  • 2022-02-02
猜你喜欢
  • 2022-12-23
  • 2021-06-30
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
相关资源
相似解决方案