student class

package myProject;

 

public class Student {

       private String firstName,lastName,grade;

       private int [] math;

       private int [] heb;

       private int [] cs;

             

       public Student(String firstName, String lastName, String grade) {

              this.firstName = firstName;

              this.lastName = lastName;

              this.grade = grade;

              this.math = new int[10];

              this.heb = new int[10];

              this.cs = new int[10];

             

              init();

       }

      

       private void init(){

              for (int i=0;i<math.length;i++){

                     math[i] = (int)(Math.random()*80+20);

                     cs[i] = (int)(Math.random()*80+20);

                     heb[i] = (int)(Math.random()*80+20);

              }

       }

      

       public void printStudent(){

              System.out.println("first name : "+firstName);

              System.out.println("last name : "+lastName);

              System.out.println("grade : "+grade);

              System.out.print("Math grades : ");

              for (int i=0;i<math.length;i++){

                     System.out.print(math[i]+",");

              }

              System.out.println();

              System.out.print("heb grades : ");

              for (int i=0;i<heb.length;i++){

                     System.out.print(heb[i]+",");

              }

              System.out.println();

              System.out.print("cs grades : ");

              for (int i=0;i<cs.length;i++){

                     System.out.print(cs[i]+",");

              }

              System.out.println();

       }

             

}

 

כתיבת תגובה