package com.sf.day07;

public class StudentTest {
    public static void main(String[] args) {
        Student student1 = new Student();
        Student[] students = new Student[5];   //动态定义数组
        for (int i = 1;i<=5;i++){
            students[i-1] = new Student();
            students[i-1].number = i;
            students[i-1].score = (int)((Math.random()*100)+1);
            students[i-1].state = (int)((Math.random()*5)+1);
        }
        //打印所有学生的信息
        
//        for (int i =0 ;i<5;i++){
//            System.out.println(students[i]);
//        }
// for增强  元素的类型  元素的变量名                  要被遍历的数组或集合     快捷键  iter+回车
        for (Student student : students) {
            System.out.println(student);
        }

        //打印出3年级(state值为3）的学生信息。
        System.out.println("打印出3年级(state值为3）的学生信息。");
        for (int i = 0;i<5;i++){
            if(students[i].state ==3){
                System.out.println(students[i]);
            }
        }
    }
}
