什么是teacher.input(得分[i],i);意思?

时间:2014-09-11 11:11:30

标签: java input

我的编码如下:

public class teacher2 {
    Score[] Score;

    public teacher2() {
        Score = new Score[10];
        for (int i = 0; i < Score.length; i++)
            Score[i] = new Score();
    }

    public void input(float[] score, int id) {
        Score[id].setScore(score);
    }

    public void check() {
        int count;
        for (int i = 0; i < 5; i++) {
            count = 0;
            for(int j = 0; j < Score.length; j++) {
               if (Score[j].getScore(i) >=60)
               count++;
            }
            System.out.println("pass rate of class " + i + " is: " + (count /10.0) * 100 + "%");
        }
    }

    public static void main(String[] args) {
        teacher2 teacher = new teacher2();
        float[][] score = {
                { 45, 56, 88, 96, 78 },
                { 77, 85, 65, 89, 75 },
                { 86, 96, 75, 98, 90 },
                { 52, 78, 95, 45, 25 },
                { 45, 12, 69, 88, 56 },
                { 45, 56, 88, 96, 78 },
                { 77, 85, 65, 89, 75 },
                { 86, 96, 75, 98, 90 },
                { 52, 78, 95, 45, 25 },
                { 45, 12, 69, 88, 56 },
        };      
        for (int i = 0; i <10; i++){
            teacher.input(score[i], i);
        }
        teacher.check();        
    }
}
  1. 我想知道teacher.input(score[i], i);是什么意思,因为当我在线搜索&#34;输入&#34;关键字,所有出来的都是关于input.netline();
  2. 并且对于最后一行,当我们想要检查时,不需要输入编码,只需输入variable.check()?
  3. 任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:0)

它调用对象input中的方法teacher。您已经在代码中进一步定义了该方法:

public void input(float[] score, int id){
    Score[id].setScore(score);
}

您还在教师对象中定义了方法check,该方法不接受任何参数,这就是您可以使用空参数列表check()调用它的原因。

答案 1 :(得分:0)

teacher.input(score[i], i);

input实例上调用teacher2方法。

不确定你的意思&#34;不需要输入编码&#34;,check方法就是你要运行的,是吗?

相关问题