关于#Java#自学,方法定义,

我自己注释了类定义,在每个方法的空白区域内添加方法定义,用点表示,就像我前面注释所。

      { private String name; // the student’s full name
         private String id; // the student ID
         private int credits; // the amount of credits for study taken so far
 // Create a new student with a given name and ID number.
 public Student (String fullName, String studentID)
          { name = fullName;
            id = studentID;    
            credits = 0; }
 // Return the full name of this student.
   …………………………………………………..
 // Set a new name for this student.
    …………………………………………………..
 // Return the student ID of this student.
    ………………………………………………….
 // Add some credit points to the student’s accumulated credits.
                              ………………………………………………………………………

 /* Check the number of credit points this student has accumulated.
 * If it is less than 132, then print “Not yet graduated”, otherwise print “Graduated”.
 */     
    for (i=0; i<2; i++) { 
           System.out.print("Enter Marks of Subject"+(i+1)+":");
           marks[i] = scanner.nextInt();
           total = total + marks[i];   }
        scanner.close();

   ……………………………………………………………………       

      
      // Print the student’s name and ID number to the output terminal.
     ………………………………………………………

```……………..

这看着就是个学生类,有名字 学号 学分 三个字段,一个构造方法包括名字和学号且学分初始为0,注释的...的部分是要补充还是什么?下边的for循环没看出来有什么用,写法是是需要写在方法里边的。你这个主要想问的问题是什么?

底下这个for要放到一个方法函数里

是你写的乱还是复制过来的乱,看着难受